Mount the Deepdesk SDK

Instantiate the Deepdesk SDK for each conversation and mount it on the agent's textarea in the customer engagement platform.

// Instantiate the Deepdesk SDK
// With <accountname>
// OR <accountname>
const deepdeskSDK = new DeepdeskSDK({
deepdeskUrl: 'https://<accountname>',
// Retrieve an existing conversation
// by platform's conversation/thread/case identifier.
// This assumes that the webhooks have been implemented.
await deepdeskSDK.getConversationBySessionId('123', {
attempts: 3,
// Set visitor info.
// Used to replace in in the placeholder variables in the suggestions
// "Goodmorning {vistor_name}!" -> "Goodmorning Anne!"
visitorName: 'Anne',
// Set agent info.
// Used to replace in in the placeholder variables in the suggestions
// "You are chatting with {agent_name}." -> "You are chatting with Sam."
// (Yes, {agent_name} uses `agentNickname` and not `agentName`)
agentName: 'Sam de Pam',
agentNickname: 'Sam',
// Get a reference to the agent's input element.
const inputElement = document.getElementById('textarea');
// Update the input field when user selects a suggestion.
// See 'Api Reference' > 'DeepdeskSDK' for more events.
deepdeskSDK.on('select-text-suggestion', suggestion => {
inputElement.value = suggestion.text;
// Update the input field when user resets / undoes suggestion selection.
deepdeskSDK.on('reset', suggestion => {
inputElement.value = suggestion.text;
// Mount the instance on the input element.
// Should be after async `createConversation` or `getConversationBySessionId`
// The SDK will render the tab completion and suggestions overlay.
// And it will start listening to events.

Notify message submit and refresh suggestions

Because the SDK can't realiably determine when the agent submits a message, the platform has to notify the SDK when an agent successfully submits a message, but before the text input is cleared.

// After an agent successfully submit's a message,
// but before the text input is emptied.
// The `notifySubmit` resets the text suggestions.
// Refresh the suggestions after the message is sent to the platform's backend,
// AND the Deepdesk webhook as been called.
// Platform frontend --> platform backend --> Deepdesk webhook