Add metadata to bot's answer in custom action

Is it possible to add some extradata to the bot’s answer inside some custom action? I’ve seen the possibility to make my own channel, but in this case it seems to be too much for a simple thing. My ideia was to make human handoff by passing a special info in metadata, since we have another system between rasa and end users and it can hence stop sending messages to rasa.

I’ve just found that I can send any custom infomation from the bot to the outside channel via json_message argument on the message, but it was not as simple to find that on the docs, I’ve found digging into the code. A simple human handoff to pass to the middle-ware system between Rasa and users can be the following, where this middle system will always look into a custom flag asked_for_humans:

class ActionHumanHandoff(Action):
    def name(self) -> Text:
        return "action_human_handoff"

    def run(
        self,
        dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any],
    ) -> List[Dict[Text, Any]]:

        dispatcher.utter_message(
            json_message={"asked_for_humans": "true"},
        )

        return []
1 Like