-
-
Save david-roark/c3a4977a53f551017a6c6733aa2ab6aa to your computer and use it in GitHub Desktop.
How to add Carousels on Rasa-webchat by Botfront
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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