Webchat Template
Default Context
Setting up the default context to manage ongoing webchat conversations
The default context handles the ongoing conversation after the initial connection is made.
What is the Default Context Used For?
- Handle interactions between the user and other systems in stubber
- React and respond to the user's incoming messages
- Create a
stubsessionbetween the new stub and the webchat session for ongoing communication
Setting Up the Default Context
Navigate to default context and click on
Edit FlowCreate Basic Flow Structure
- Create a state called
pending-message(This will be the state that the stub will be in when replying to messages) - Add an action called
reply(This action will send a message to the webchat client) - Add an action called
_create(This action runs when the stub is created) - Add an action called
_update_from_webchat(This action will be used to trigger a reply when a user sends a message)

- Create a state called
Configure the Reply Action
In the
replyaction, add theWebchat notification to sessionfrom the library and configure it as follows:Change
webchat.sessionuuidvalue to~~stub.data._incoming_webchat_data.sessionuuid. This will allow the notification to send a message to the correct client.Configure the _create Action
In the
_createaction, add the taskSend actionfrom the library and configure it as follows:This will trigger a reply when the new stub is created. Once the reply is sent, a stubsession will be created between the new stub and the webchat client, allowing all future messages to be routed into the
_update_from_webchataction.
Configure the _update_from_webchat Action
To respond to future messages, add the task
Send actionto_update_from_webchat:Now all future messages will be handled by the conversation stub:
