Custom buttons in action.py file

You can do this in custom actions. I believe you need to fetch that data from your DB. When the user asks give me mobile no. xx, first you need to capture the name of that person in a slot.

Then in your custom actions make your API call to the DB or however you want to fetch the user details. Use

# Fetch the data and store in the format used by buttons.
buttons = [{"title": "Rohan Shah", "payload": "/intent_name"}, {"title": "Rohan Pandya", "payload": "/intent_name"}]
dispatcher.utter_button_message("There are 2 people with the name Rohan:", buttons)

Once the user selects a button again trigger custom actions and fetch his details.

8 Likes