arduino uno r3 + 12v NPN photoelectric switch through beam sensor

im having trouble to read the output from the sensor. The sensor is sensing the object interrupted but the arduino is like not receiving the signal that is suppose to energize my relay when the signal is received. is it because i use external supply (12v) ?

Is this the same sensor you're using in this thread?

What was wrong with the other thread?

the other thread do not include relay. sorry