My first guess with such behavior would be a loose/broken wire somewhere, or a loose/corroded connector. I would inspect the ABS wiring to the sensors as the first easy step.
I would also flush the brakes and get new brake fluid into the system if you have never done this since new (sometimes crud forming in the system can affect valves and actuators).
I would also flush the brakes and get new brake fluid into the system if you have never done this since new (sometimes crud forming in the system can affect valves and actuators).