To do this, go in to the Message Popup step Properties tab:
Go to the Post-Expression box in the Expressions settings:
Enter the following expression:
Locals.<variable name> = Step.Result.ButtonHit
This will retrieve the name of the button that was pressed (Step.Result.ButtonHit) and save it in the specified local variable as a string.