... A variation of something previously mentioned:
Arrange three light bulbs ... incandescent or whatever ... to indicate which particular phase has power at the changeover.
You would have one light bulb on each phase, powered by a phase to neutral connection.
Each light bulb would turn on a particular photo-transistor ... indicating the active phase, and sending a signal to the controller.
The controller would turn on the appropriate relay that would provide power to the motor, while turning the two inactive relays off.
The logic condition that would indicate the switching of the three phase would simply be the state in which you do not have all three light sources turned on.