In a way, we could describe a conventional joke as one that follows the structure of ‘This’ and ‘That’.

It starts with ‘This’ (first story) and instead of concluding that story (still ‘This’) it takes a step in a different direction to ‘That’.
The bigger, or better, the step that is taken (one could argue) the more effective the joke – usually resulting in laughter.

If one had to describe to an alien entity (like Ai) how most jokes work, you could use this sort of language – and it would involve expectation and surprise* i.e. ‘This’ and ‘That’ – with ‘That’ being unexpected.
“It was going ‘this way’ and then ‘that’ happened…”

*Tim Minchin mentions this in a conversation with Jimmy Carr one time. And it is that simple.

And if you look at many a joke, it will have some degree of misdirection built in so to make the punch ‘work’, so the set up was already expecting the punch – afterall, it was written that way on purpose.