One way to do it is with the overlapping at offset condition. So say the ai sprite's size is 32x32 you could do this:
[inverted] ai is overlapping ground at offset (-32,32)
--- ai set angle to 0
[inverted] ai is overlapping ground at offset (32,32)
--- ai set angle to 180