Hello! I’ m new to the Rasa Stack. I 'm making a chatbot with 2 buttons. It works on the backend but I can’t display buttons in flask, only the titles of them. Could someone help me please?
@chrysapap can you share some code for the reference are you using render_template and mentioned the .html page right? I personally not implemented this approach (its intresting)
Yeah that’s right. Here is my actions.py file:
class ActionService(Action):
def name(self) -> Text:
return "action_service"
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
buttons=[
{"payload" : "/what_c", "title": "What is covid-19?"},
{"payload" : "/symptoms", "title": "What are the symptoms of covid-19?"}
]
dispatcher.utter_message("I can help you!",buttons=buttons)
return []
@chrysapap Can you format the second code for me and always tag me.
@nik202 and the app.py file:
def chatbot_response():
msg = request.form["msg"]
data = json.dumps({
"sender": "Rasa",
"message": msg
})
headers = {'Content-type': 'application/json', 'Accept': 'text/plain', }
res = requests.post('http://localhost:5005/webhooks/rest/webhook', data= data, headers = headers)
res = res.json()
resp=[]
for i in range(len(res)):
message = {
"": res[i].get("text")
}
if res[i].get("buttons"): e
options = [b.get("title") for b in res[i].get("buttons")]
message["options"] = options
resp.append(message)
result=resp
return str(result)
So I get this as result: