Filament sensor and Octopi

I have an Ender 3 v3 se with stock firmware (1.0.6 iirc) and am running Octopi on a Pi3b

I am trying to add a Creality filament runout sensor.

I have mounted the sensor on the gantry but would appreciate some help on connecting it up.

If I plug it in to the printer, will the printer tell the Pi to stop the printer?

Or if I connect the sensor direct to the Pi, where do each of the 3 cables go on the Pi pins?