How to define utter_template, can show quick reply on facebook

@tuyendh. Feel your pain. Frankly I’m getting a little tired of the vague answers on this forum, and the ambiguous / unclear / outdated documentation online, including the zillions of broken links to existing documentation which 301 redirects back to the rasa homepage …

To the moderators / admins, one line answers with no material direction or valid solution just drive me up the wall, I am sure that I am not the only one.

As far as I can tell, there is a bug (See Here) with including ‘quick_replies’ array in the domain.yml file, however, the following worked for me:

class ActionYesNo(Action):
    def name(self):
        return "action_yes_no"

    def run(self, dispatcher, tracker, domain):
        if tracker.get_latest_input_channel() == 'facebook':
            message = {
                "text": "Is this correct (Yes/No)?",
                "quick_replies": [
                    {
                        "content_type": "text",
                        "title": "Yes",
                        "payload": "/affirm",
                    }, {
                        "content_type": "text",
                        "title": "No",
                        "payload": "/deny",
                    }
                ]
            }
            dispatcher.utter_custom_json(message)
        else:
            dispatcher.utter_template("utter_yes_no", tracker)
        return []

Basically it is an action that utters custom JSON (including quick replies) if the latest input channel is facebook, else, it utters a simple template which you can define in the domain.yml file.

Not sure if the quick replies work on other channels, for me its binary, either on facebook or console. The quick replies are undesired if the channel is the console (ie rest channel).

Facebook messenger screenshot below…

Console screenshot below

6 Likes