Hey @bourrel the only way to generate it dynamically is to use custom actions.
since there is no code where you write your stories, if you add a new story you have to manually put a button to initially that specific story.
Alternatively, could map all of you desired paths into a python dict, and programmatically (Through rasa actions) make your bot read the list before showing the buttons. You still would have to do some manual work which is to write down the story
info into that python dict
You could right a class like this:
class Options:
''' All the other option the Bot might show '''
def general_options(self, display_message, buttons)-> Dict:
'''
Return/display a dict with the options based on input
display_message : utter to be displayed
buttons: A dict with all the buttons of the utter
'''
result_list = []
for elements in buttons:
for title, payload in elements.items():
result_list.append({title:payload}) # append titles and pyload as dict
message = {
"text": display_message,
"quick_replies":
buttons
}
return message
and then run your function like this:
def run(self, dispatcher,tracker,domain):
display_message = 'how do you feel today ?'
buttons =[
{
"content_type": "text",
"title": "good",
"payload": "good" # go to bad story
},
{
"content_type": "text",
"title": "bad",
"payload": "bad" # go to bad story
}
# Add more buttons here
]
message = Options().general_options(display_message, buttons)
if you create another story, you would just have to add that to your buttons
list, like so:
def run(self, dispatcher,tracker,domain):
display_message = 'how do you feel today ?'
buttons =[
{
"content_type": "text",
"title": "good",
"payload": "good"
},
{
"content_type": "text",
"title": "bad",
"payload": "bad"
},
# New story added
{
"content_type": "text",
"title": "extremely well",
"payload": "I feel extremely well" # go to extremely well story
},
]
message = Options().general_options(display_message, buttons)
Hope that helps,
Cheer