Hello everyone,
RASA version: 1.10.1
RASA CDK: 1.10.1
Similar to the Raspberry Pi example in the RASA documentation external events, I have an external process that needs to modify the conversation based on customer behavior.
My development p.o.c utilized the trigger_intent API endpoint. In a one CORE server configuration the expected behavior was successful!!
To mirror the production environment, I decided to test the functionality with a multiple CORE server implementation locally. I suspected that if a conversation started on core_server_1 but the load balancer routed the external trigger_intent POST request to core_server_2, the user would not receive the utterance that accompanies the intent even if the intent was correctly injected. My tests results appear to confirm this behavior.
run multiple core instances locally:
docker-compose --scale core_server=3
docker-compose ps
a_core_server_1 rasa run --cors * --enable ... Up 0.0.0.0:32794->5005/tcp
a_core_server_2 rasa run --cors * --enable ... Up 0.0.0.0:32793->5005/tcp
a_core_server_3 rasa run --cors * --enable ... Up 0.0.0.0:32792->5005/tcp
a_lock_store_1 docker-entrypoint.sh redis ... Up 0.0.0.0:6379->6379/tcp
a_tracker_store_1 docker-entrypoint.sh postgres Up 0.0.0.0:5432->5432/tcp
In my client I forced the connection to Core Server on localhost:32794 and upgraded to wssocket protocol. With Postman I tested the external trigger intent:
POST: http://localhost:32794/conversations/12345/trigger_intent?output_channel=socketio
BODY:
{
"name": "greet",
"entities": {
}
}
Event in RESPONSE:
{
"event": "user",
"timestamp": 1591477068.711168,
"metadata": {
"is_external": true
},
"text": "EXTERNAL: greet",
"parse_data": {
"intent": {
"name": "greet"
},
"entities": [],
"text": "EXTERNAL: greet",
"message_id": null,
"metadata": {
"is_external": true
}
},
"input_channel": null,
"message_id": null
},
{
"event": "action",
"timestamp": 1591477068.7393892,
"name": "utter_how_can_i_help",
"policy": "policy_1_AugmentedMemoizationPolicy",
"confidence": 1.0
},
{
"event": "bot",
"timestamp": 1591477068.739402,
"text": "Hi! How can I help you??",
"data": {
"elements": null,
"quick_replies": null,
"buttons": null,
"attachment": null,
"image": null,
"custom": null
},
"metadata": {}
},
The correct intent response would be utter to the client: “Hi how can I help you”
Changing the port to send the POST to server_2 will not display the utterance back to the user despite processing the external event correctly.
http://localhost:32793/conversations/12345/trigger_intent?output_channel=socketio
core_server_2 | 2020-06-06 21:04:00 DEBUG rasa.core.processor - Action 'utter_how_can_i_help' ended with events '[BotUttered('Hi! How can I help you??'
This to me makes sense since the socket connection was never set with core_server_2 so I does not know where to reply back to!
I guess my question is: How should I set this up if I am running multiple core servers behind a load balancer and the POST requests to the API could be routed to a different C.S than the one the client established a connection from? Is this possible to achieve?
Regards
Setup
docker-compose:
core_server:
image: rasa/rasa:1.10.1-full
ports:
- "5005"
command: >
run
--cors '*'
--enable-api
--debug
--endpoints endpoints.yml
--credentials credentials.yml
endpoints:
action_endpoint:
...
tracker_store:
dialect: "postgresql"
lock_store:
type: "redis"