Details
-
Spike
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
chat 3.18.0
-
None
-
None
-
Software (SOFTWARE)
-
Sprint# 60 (Nov 1-12), Sprint# 61 (Nov 17 - Dec 1), Sprint# 62 (Dec 6 - 17)
Description
Current Implementation
- A customer sends a message. Chat Server sends the message to the Bot Connector
- Bot Connector calls Rasa API to get a response to a message
- Rasa responds with multiple messages for the detected intent. It responds with the following payload:
response: { ..., "data": [ { "recipient_id": "VCIyIoTXp2FLAbH7eq1Kk", "text": "msg 1" }, { "recipient_id": "VCIyIoTXp2FLAbH7eq1Kk", "text": "msg 2" }, { "recipient_id": "VCIyIoTXp2FLAbH7eq1Kk", "text": "msg 3" }, { "recipient_id": "VCIyIoTXp2FLAbH7eq1Kk", "text": "msg 4" }, { "recipient_id": "VCIyIoTXp2FLAbH7eq1Kk", "text": "msg 5" }, { "recipient_id": "VCIyIoTXp2FLAbH7eq1Kk", "text": "msg 6" }, { "recipient_id": "VCIyIoTXp2FLAbH7eq1Kk", "text": "msg 7" }, { "recipient_id": "VCIyIoTXp2FLAbH7eq1Kk", "text": "msg 8" }, { "recipient_id": "VCIyIoTXp2FLAbH7eq1Kk", "text": "msg 9" }, { "recipient_id": "VCIyIoTXp2FLAbH7eq1Kk", "text": "msg 10" } ], ... }
- Bot Connector iterates over these messages and sends them one by one to Chat Server. It is due to a limitation of the Chat Server message payload where one can send only one text body per message. So bot connector sends the following payload one by one to Chat Server
{ "conversationId": "VCIyIoTXp2FLAbH7eq1Kk", "messageId": "9af18a53-7680-44d9-854e-90de9bdf72fe", "type": "BotMessage", "from": { "id": "Vjx3vYztjRV51_c_VV_q4", "name": "customer name", "firstName": "customer name", "lastName": "", "type": "Customer" }, "bot": { "id": "bot", "name": "EF Bot", "type": "Rasa", "botResponseType": "simple" }, "timestamp": "2021-12-10T12:36:03.954Z", "input": "hi", "attachments": [], "intents": [ { "name": "greet", "confidence": "0.988152801990509" } ], "entities": [], "output": [ { "name": "message text body", "confidence": "0.988152801990509", "data": { "elements": "null", "quick_replies": "null", "buttons": "null", "attachment": "null", "image": "null", "location": "null", "custom": "null" } } ] }
Although the output object is an array of objects, Chat Server only supports one object in this array.
- Chat Server sends this payload to CCM (for non-web channels) via ActiveMQ channel queue
- CCM consumes these messages from the ActiveMQ channel queue in an asynchronous fashion and sends them to the destination. The order of these messages cannot be guaranteed because of the asynchronous nature of the CCM process
Proposed Solution
- When Bot Connector receives the array of messages from Rasa API. It should send them to the Chat Server in the following payload
{ "conversationId": "VCIyIoTXp2FLAbH7eq1Kk", "messageId": "9af18a53-7680-44d9-854e-90de9bdf72fe", "type": "BotMessage", "from": { "id": "Vjx3vYztjRV51_c_VV_q4", "name": "customer name", "firstName": "customer name", "lastName": "", "type": "Customer" }, "bot": { "id": "bot", "name": "EF Bot", "type": "Rasa", "botResponseType": "simple" }, "timestamp": "2021-12-10T12:36:03.954Z", "input": "hi", "attachments": [], "intents": [ { "name": "greet", "confidence": "0.988152801990509" } ], "entities": [], "output": [ { "name": "message text body 1", "confidence": "0.988152801990509", "data": { "elements": "null", "quick_replies": "null", "buttons": "null", "attachment": "null", "image": "null", "location": "null", "custom": "null" } }, { "name": "message text body 2", "confidence": "0.988152801990509", "data": { "elements": "null", "quick_replies": "null", "buttons": "null", "attachment": "null", "image": "null", "location": "null", "custom": "null" } }, { "name": "message text body 3", "confidence": "0.988152801990509", "data": { "elements": "null", "quick_replies": "null", "buttons": "null", "attachment": "null", "image": "null", "location": "null", "custom": "null" } }, ... ] }
- Chat Server will parse the output object as a single message and will send it to the CCM via the ActiveMQ channel queue
- CCM will consume this message from the ActiveMQ channel queue and will parse this message asynchronously. Now that this message contains multiple text bodies, CCM will iterate over this array in a synchronous fashion, sending them one by one and maintaining the order.
Attachments
Issue Links
- has to be done before
-
CSN-5769 Send Multiple Bot Responses in a single message
- Deploy-Ready