https://docs.duet3d.com/User_manual/Reference/Gcodes#m591-configure-filament-sensing
depending on type of filament sensor you are using things change . If its a switch, you need to know if it is normally open or closed that determines whether you have filament or you don't. if you want it to detect and pause during print.
for normally open switch
M591 P1 C"e0stop" S1 D0 ; filament sensing during print
if that didnt work just try P2
you can also setup sensor to detect filament and auto load in new firmware, which you need to make trigger file for. i suggest you get this covered first.