Open a conversation
Updated
sprChat('openNewConversation')
This API can be used to start a new conversation on behalf of the user. The conversation will start with the welcome messages that were configured in the application builder.
Parameters
(every parameter is optional unless marked *):
Name | Typescript type | Description | Default Value |
initialMessages | Array<{ isSentByUser?: boolean; message: string | Partial<Message> } | string> | Override the default welcome messages by the supplied array. | None. |
autoInitiateConversation | boolean | Need to create a case without any user message | No |
conversationContext | StringTMap<string[]> | Pass some kind of context along with new conversation | No |
Examples
Starts a conversation with welcome messages that were configured in application builder
window.sprChat('openNewConversation'); |
Starts a conversation with 1 brand message and 1 user message
window.sprChat('openNewConversation', { |
Starts a conversation with “_c_abcdef123” custom field and its value “123”.
window.sprChat('openNewConversation', { |
sprChat('openExistingConversation')
This API can be used when we want to open the latest active and open conversation (ie, unclosed + undeleted + having the most recent published message) of the user.
It can also be used to open a particular conversation, if you have the ID captured (by listening to some events that declare the ongoing conversation). Use this only and only if you want to open an old, open conversation.
Parameters:
(every parameter is optional unless marked *):
Name | Typescript type | Description | Default Value |
conversationId | string | Sprinklr defined conversation ID | Latest active and open conversation |
Examples
1. Automatically opens the latest active and open conversation
window.sprChat('openExistingConversation', 'conv_123'); |
2. Open 'conv_123' conversation
window.sprChat('openExistingConversation', 'conv_123'); |