from phase 1. connect a transformer that converts 220v to 12v dc and power the 8 point relay with it.
similarly do that for phase 2 and phase 3.
now you have three 8 point relays working each powered by a single phase of you wapda simultaneously............
now the signal wire for generator goes via these three relays in series such that if any one phase fails, gen gets started..................
attached three (220v Ac )25 ampere or more ampere relay on each phase....for each relay the common terminal goes to that phase home load..... the normally close point goes to generator 220v AC output...........the normally open goes to respective phase i.e 220v AC main wapda line...