Entry Points
You can create workflows that trigger at different points in a chat’s lifecycle:
When the chat window opens for the first time
This happens either when a chat is opened for the very first time or after an existing chat is closed and a new one begins.
To handle this, define a function named chatOpened. This function will be called when the chat opens for the first time and will receive a context object (ctx) as its parameter.
Note: If a workflow is triggered by chatOpened, the chatStarted workflow will not be triggered for the same chat session.
function chatOpened(ctx) {
// Your code here
}
When a new chat starts
This occurs when the customer sends their first message in a chat session.
To handle this, define a function named chatStarted. This function will be called at the start of the chat and will receive a context object (ctx) as its parameter.
Note: If a workflow is triggered by chatOpened, the chatStarted workflow will not run for that chat session.
function chatStarted(ctx) {
// Your code here
}
When interacting with workflow events, callback functions receive a context object (ctx
) that contains information about the current state:
For message handlers:
ctx.lastMessage
: The most recent message received from the user.
Comments
Can’t find what you need? Use the comment section below to connect with others, get answers from our experts, or share your ideas with us.
There are no comments yet.