Sending custom payload for rich responses from Rasa using API


I am using Rasa 2.8.13.

I wish to use a Main Bot (port 5005) whose Action Server (port 5055) would act as a messaging router to different APIs, micro-services or other Rasa Sub bots.

In my Action Server for the Main Bot (port 5055), I send a post request to another Rasa Sub-Bot (port 5006) and whose Action Server (port 5056) sends back rich responses such as images, buttons, videos or carousels.

I tried these out and they work in the case of a single bot/action server where the rendering is done using Rasa Webchat.

My question is how to have these payloads sent as a response to the post request.

Action server at port 5055:

 response ='http://localhost:5006/webhooks/rest/webhook',data=json.dumps(data), headers=headers)
 response_dict = json.loads(response.text)

Action server at port 5056 for sub-bot running on port 5006:

dispatcher.utter_message(text="Check this image", image="Rasa.png")

The above code works when there is a single bot accessed via Web Chat. What change should I make in the utterance when I access the Rasa sub-bot via a webhook from the action server of the Main Bot?

I managed to work around the issue by including a message processing function in the action server of the Main Bot. Upon receiving the JSON payload from the HTTP API post request to the sub-bot, the action server re-dispatches the payload depending on the message type.