Webchat
Webchat template default context
Setting the default context for handling webchat messages
What is the default context used for?
- Handle interactions between the user and other systems in stubber
- Reacting and responding to the users incoming messages
- The default context has to reply to the user so that a
stubsession
is created between the new stub and the webchat session
Navigate to default context and click on Edit Flow
Replying to a users first message
- Create a state called
pending-message
. This will be the state that the stub will be in when replying to the message - Add an action called
reply
. This action will send a messages to the webchat client. - Add an action called
_create
. This action runs when the stub is created. We want to override this action so that the new stubs first action is replying. You can trigger any actions provided you send a reply. - Add an action called
_update_from_webchat
. This action will be used to trigger a reply to the webchat when a user sends a message
- Data for the webchat client will be present at
stub.data._incoming_webchat_data
- In the
reply
action add theWebchat notification to session
from the library. changewebchat.sessionuuid
value to~~stub.data._incoming_webchat_data.sessionuuid
. This will allow the notification to send a message to the correct client.
In the
_create
action add the taskSend action
from the library. Change theparams.action_name
toreply
. This is to trigger a reply when the new stub is created. Once the reply is send a stubsession will be created between the new stub and the webchat client allowing all future messages to be routed into the action_update_from_webchat
.Change the
params.message
to the valueA stub has been created
. This is so that we can identify what action triggered the reply
Replying to a users future messages
- To run actions when a user send a message we need to add the task
Send action
to_update_from_webchat
. - Change the
params.message
to the valueConversation stub is now handling all future replies
. This is so that we can identify what action triggered the reply
- Now all future messages will be handled by the conversation stub as seen below