Probably best to put it at the start, I'm assuming they have defensive units pre-placed? If so do a
Call SetBuildUnitEx(1,2,3,'hfoo')
for every defender unit and the computer will replace them infinitely if they're killed. That example there has Ex at the end for the 3 different difficulties: easy, normal and hard and then the unit's ID at the end, in this case the Human Footman. If you do this for buildings it will replace any pre-placed buildings that are destroyed.
So if I have an enemy barracks on the map
and CallSetBuildUnitEx(1,1,1,'hbar')
Any time that barracks is killed, the AI will rebuild it.
You'll want it before the InitAssaultGroup(), the InitAssaultGroup() just prepares Captains IIRC, the call CampaignAttackerEx checks if they have enough units and if not to train more. However the way that script works is for training units not building them, so it'll never build the War Golems but would assign War Golems that are already built or pre-placed.