Webchat Template
Create Context
Setting up the create context to handle initial webchat connections
The create context is responsible for receiving the first message from a webchat user and initializing a new conversation stub.
What is the Create Context Used For?
- In order to interact with end users through webchat, you need to have a stub that manages incoming traffic
- The create context specifies actions that handle the first message a user sends from webchat
- A stub will be created from the create context, and this stub will handle webchat events
Setup Options
You have two routing options for your webchat traffic:
Option 1: Stubref Routing (Recommended for Most Cases)
Navigate to the create context and open the canvas
Create an action called
_update_from_webchatYour canvas should look like this:

Configure Create Stub Task
In the
_update_from_webchataction, add the taskcreate_stub (with data)from the task library:
Configure with the following parameters:
Data from the webchat service is placed in
stub.data._incoming_webchat_data. To pass this data to the new stub, we configureparams.data._incoming_webchat_datato have the value~~stubpost.data._incoming_webchat_data.Test Your Webchat Client
You will see that a draft stub was automatically created for you
Open that stub and copy the stubref

In your
webchat profile, select thedraftbranch and enableSend webchat traffic to stub
Paste your copied
stubrefinto the stubref field
Open your webchat client and send a message
After sending a message, the webchat service will execute the
_update_from_webchataction
Option 2: Heimdall Routing (For Advanced Use Cases)
Navigate to the create context and create an action
register_heimdall_pathsYour canvas should look like this when complete:

Configure Heimdall Register Task
In
register_heimdall_paths, add the taskheimdall_registerfrom the task library:
Configure with the following parameters:
Important: Replace
your_chat_namewith the Chat name from your webchat profile.
Configure Create_Stub Action
In
create_stub, add the taskcreate_stub (with data)from the task library:
Configure with the following parameters:
Data from heimdall events is placed in
stub.data.heimdall.webchat. We want to pass this data to the new stub as it contains thewebchat session uuidused to reply to a specific webchat instance.Test Your Webchat with Heimdall
Create a draft stub and run the action
register_heimdall_paths
Open your webchat client and send a message
After sending a message, heimdall will execute the
create_stubaction