How to create a button in actions.py

Hi,

I am trying to create a buttons in actions.py file. I have 10 dates. each and every date have to be display in buttons. At the same time, my dates are coming from database, not in intents.
dispatcher.utter_button_message(message, buttons) is not working

Thanks

Hi @ramyaps!

Which version of rasa are you using?

Hi,

Rasa version - 1.7.0 Rasa X- 0.25.1

Thanks

utter_button_message is deprecated, use dispatcher.utter_message(text=message, buttons=buttons) instead. Also could you post what you are passing in buttons?

I have tried both the things, its not worked.

Hi,

This is the one I am using
buttons = [ ]
for t in output_dict:
date = output_dict[‘t’]
payload = “/date”
buttons.append({“title”: “24-2-2020”, payload: “/date”})
dispatcher.utter_button_template(buttons)

Thanks

Hmm, this seems correct. Could you explain what is not working? Like, are the buttons not getting rendered correctly? If so, which channel are you using to render it?

hi,
This is the code i am using in actions.py file.

buttons = [ ]
for t in output:
new = t[‘date’]
payload = “/date”
buttons.append( {“title”: “{}”.format(new.title()),
payload: ‘/date{“name”: “24-2-2020”}’})
dispatcher.utter_button_template(“utter_greet”,buttons, tracker)
return [ ]

I am getting a buttons like this.
25-2-2020 27-2-2020 28-2-2020
when i click on this 25-2-2020 button, it should navigate to the next step. This navigation is not working.

Thanks

The issue seems to be related to stories because buttons are getting rendered correctly. Also I see that you are deploying the same payload regardless of the title of the button. Have you checked the logs to see if you intent is getting correctly classified and are your stories getting followed correctly?

can you show the syntax of payload button in action file. because it gives complete error in my file. but i can get it in domain file