Skip to content

Instantly share code, notes, and snippets.

@david-roark
Forked from Horizon733/actions.py
Created August 29, 2023 13:57
Show Gist options
  • Select an option

  • Save david-roark/c3a4977a53f551017a6c6733aa2ab6aa to your computer and use it in GitHub Desktop.

Select an option

Save david-roark/c3a4977a53f551017a6c6733aa2ab6aa to your computer and use it in GitHub Desktop.
How to add Carousels on Rasa-webchat by Botfront
class ActionCarousel(Action):
def name(self) -> Text:
return "action_carousels"
def run(self, dispatcher, tracker: Tracker, domain: "DomainDict") -> List[Dict[Text, Any]]:
message = {
"type": "template",
"payload": {
"template_type": "generic",
"elements": [
{
"title": "Carousel 1",
"subtitle": "$10",
"image_url": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSqhmyBRCngkU_OKSL6gBQxCSH-cufgmZwb2w&usqp=CAU",
"buttons": [
{
"title": "Happy",
"payload": "Happy",
"type": "postback"
},
{
"title": "sad",
"payload": "sad",
"type": "postback"
}
]
},
{
"title": "Carousel 2",
"subtitle": "$12",
"image_url": "https://image.freepik.com/free-vector/city-illustration_23-2147514701.jpg",
"buttons": [
{
"title": "Click here",
"url": "https://image.freepik.com/free-vector/city-illustration_23-2147514701.jpg",
"type": "web_url"
}
]
}
]
}
}
dispatcher.utter_message(attachment=message)
return []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment