Class: DeepdeskSDK

DeepdeskSDK(apiUrl, accessToken, enableConversationSuggestionsopt, enableHotkeysopt, sourceopt)

new DeepdeskSDK(apiUrl, accessToken, enableConversationSuggestionsopt, enableHotkeysopt, sourceopt)

Create an instance of DeepdeskSDK.

Parameters:
Name Type Attributes Default Description
apiUrl string

A string with the base API URL for the account, e.g. https://demo.api.deepdesk.com

accessToken string

A string with the JWT access token for the account

enableConversationSuggestions boolean <optional>
true

Whether to show conversation based suggestions

enableHotkeys boolean <optional>
true

Whether to enable the suggestion keyboard shortcuts

source string <optional>

A string describing the platform making use of the SDK. This is used primarily for analytics.

Methods

createAutocomplete(containerElement, css, showToggleButtonopt)

Injects the Deepdesk Autocomplete element into the provided DOM element.

Parameters:
Name Type Attributes Default Description
containerElement DOMElement

the element to inject the deepdesk element in

css string

a CSS string, will be loaded over the default deepdesk CSS

showToggleButton boolean <optional>
false

default false - add a open/close button on the autocomplete element

createConversation(sessionId, agentId, onSuccess)

Create a conversation

Parameters:
Name Type Description
sessionId string

A string with the conversation session ID. A session ID is local to the customer service platform, and identifies a conversation that takes place within a certain time frame.

agentId string

A string with the agent ID as known within the customer service platform

onSuccess string

The callback for when the request succeeds.

handleConversationUpdate(conversation)

Method to call when the conversation is updated, either by an incoming message from the visitor, or a message sent by the agent.

Parameters:
Name Type Description
conversation Object.<string, message>

An object containing the conversation messages. This object should be a dictionary with message timestamps as keys, and message objects as values.

notifyInputChanged(text)

Method to call when the agent input has changed

Parameters:
Name Type Description
text string

The current value of the agent input

notifyKeyDown(event)

Method to call for the agent input keydown event

Parameters:
Name Type Description
event Object

The input event object

notifyMessageAgent()

Method to call when the agent has sent a message to the visitor

notifyMessageUser()

Method to call when the agent has received a message from the visitor

onUseSuggestion(handler)

Provide a callback for when a suggestion is used. This callback should paste the suggestion into the agent input.

Parameters:
Name Type Description
handler DeepdeskSDK~useSuggestionCallback

The callback

updateAgentInfo(agentInfo)

Update the agent information

Parameters:
Name Type Description
agentInfo Object

An object containing agent information

Properties
Name Type Description
agentId string

The agent ID

agentName string

The agent name

agentEmail string

The agent email

updateVisitorInfo(visitorInfo)

Update the visitor information

Parameters:
Name Type Description
visitorInfo Object

An object containing visitor information

Properties
Name Type Description
visitorId string
visitorName string
visitorEmail string
visitorPostalCode string
visitorHouseNumber string

Type Definitions

useSuggestionCallback(text)

Callback for when the agent uses a suggestion

Parameters:
Name Type Description
text string

The text of the used suggestion