make sure to send a hero with scouting missions, the higher the intell rating, the better.
make sure you build and upgrade your beacon tower, at level 5 it tells you where the attack came from, at level 8 it tells you the details of the enemy army.
make sure you check the allow allied army blocks in your embassy, this will allow us to help defend you
make sure the open gates defense block is checked at the rally point, this will allow yours and the allied troops to help defend the city, if it is unchecked, your army will be totally safe, but do nothing during the attack.