One of the main reasons I switched to Duet was because my Pulse XE printer did not come with a filament runout switch. I was told they didn't have good luck with their reliability so they discontinued the switch.
Added Creality billet aluminum filament runout switch and code. This a simple roller switch with blue led light indicator. From left to right is Signal - Ground - Power. In my case I used io_4.in for Signal, center ground and 3.3v for the power. You will need to configure P0/P1 if your switch is normally open or normally closed. When the switch is triggered, it will trigger pause.g macro. Once you have replaced the filament, you will need to manually restart the printer using the resume print button.
Any simple runout switch will work with this code. There are many of these on Thingiverse if you wish to build your own. Add this code to your config.g file, near the bottom above custom tools is where I placed mine.
; Filament Runout Switch
M591 D0 P1 C"io_4.in" S1 ; P0 P1 NO/NC