Store button title from actions.py

I need to store the title of a button from within actions.py.

I present the user with an unknown number of search suggestions which are stored in the list suggestions. This list of strings is then used to create buttons which are returned to the user. The user then selects the button with the search term they want to use, and then that term is used to do a search. So I need to have the title of the button they select stored in a slot, or retrievable in some other way. This will then be used in a different custom action. This is what I currently have:

buttons =[]
for s in suggestions:
      buttons.append({"title": s, "payload": "/search"})
dispatcher.utter_message(text="Please select your search term:", buttons=buttons)

I have tried using tracker.latest_message[‘text’] however this gives me “/search” rather than the title of the button which I want.

I have also tried storing a slot along with the button payload, but I can’t figure out the syntax to store the variable s into the slot correctly in actions.py.

The story currently looks something like this:

* find_search_suggestions
  - action_search_suggestions
* search
  - action_search

You could change the payload to "/search{'button_slot':'search'}"