Contents
WebChat Service
Commands
startChat
Initiates a new chat session with the chat server via GMS
Options
| Option | Type | Description |
|---|---|---|
| userData | object | arbitrary data to attach to the chat session (AKA attachedData). Properties defined here will be merged with default userData set in the configuration object |
| nickname | string | Override Chat Entry Form Data: 'nickname' |
| firstname | string | Override Chat Entry Form Data: 'firstname' |
| lastname | string | Override Chat Entry Form Data: 'lastname' |
| string | Override Chat Entry Form Data: 'email' | |
| subject | string | Override Chat Entry Form Data: 'subject' |
Resolutions
| Status | When | Returns |
|---|---|---|
| resolved | When server confirms session started | (AJAX Response Object) |
| rejected | When an chat session is already active | {'type':'error', 'text':'There is already an active chat session'} |
| rejected | When AJAX exception occurs | (AJAX Response Object) |
| rejected | When server exception occurs | (AJAX Response Object) |
| rejected | When userData is invalid | {'type': 'error', 'text': 'malformed JSON provided in userData property'} |
endChat
Ends the chat session with the chat server via GMS
Resolutions
| Status | When | Returns |
|---|---|---|
| resolved | When active session is ended successfully | (AJAX Response Object) |
| rejected | If no chat session is currently active | {'type':'error', 'text':'There is no active chat session'} |
sendMessage
Send a message from the client to the chat session
Resolutions
| Status | When | Returns |
|---|---|---|
| resolved | When message is successfully sent | (AJAX Response Object) |
| rejected | If no message text provided | {'type':'error', 'text':'No message text provided'} |
| rejected | If no chat session is currently active | {'type':'error', 'text':'There is no active chat session'} |
| rejected | When AJAX exception occurs | (AJAX Response Object) |
sendTyping
Send 'customer typing' notification to chat session. A visual indication will be shown to agent
Resolutions
| Status | When | Returns |
|---|---|---|
| resolved | When AJAX request is successful | (AJAX Response Object) |
| rejected | When AJAX exception occurs | (AJAX Response Object) |
| rejected | If no chat session is currently active | {'type':'error', 'text':'There is no active chat session'} |
configure
Configure the widget. See configuration page for WebChatService
Options
| Option | Type | Description |
|---|---|---|
| apikey | string | Apigee Proxy secure token |
| endpoint | string | Manually select the endpoint to initiate the chat on |
| dataURL | URL String | URL of GMS server |
| userData | object | Arbitrary JSON attached data to include when initiating a chat |
| ajaxTimeout | number | Number of milliseconds to wait before AJAX timeout |
Resolutions
| Status | When | Returns |
|---|---|---|
| resolved | When configuration options are provided and set | n/a |
| rejected | When no configuration options are provided | {'type': 'error', 'text': 'Invalid configuration'} |
getTranscript
Fetch an array of all messages in the chat session
Resolutions
| Status | When | Returns |
|---|---|---|
| resolved | Always | (Array) |
getAgents
Return a list of agents that have participated in the chat. Includes agent metadata
Resolutions
| Status | When | Returns |
|---|---|---|
| resolved | Always | (Object List) {name: (String), connected: (Boolean), supervisor: (Boolean), connectedTime: (int time),disconnectedTime: (int time)} |
getStats
Return stats on chat session including start time, end time, duration, and list of agents
Resolutions
| Status | When | Returns |
|---|---|---|
| resolved | Always | {agents: (Object), startTime: (int time), endTime: (int time), duration: (int time)} |
registerTypingPreviewInput
Select an HTML input to watch for key events. Used to trigger startTyping and stopTyping automatically.
Options
| Option | Type | Description |
|---|---|---|
| input | HTML Reference | An HTML reference to a text or textarea input |
Resolutions
| Status | When | Returns |
|---|---|---|
| resolved | When valif HTML input reference is provided | n/a |
| rejected | When invalid or missing HTML input reference | {type: 'error', text: 'Invalid value provided for the 'input' property. An HTML element reference to a textarea or text input is required.'} |
Events
| Name | Description | Data |
|---|---|---|
| ready | WebChatService is initialized and ready to accept commands | |
| restored | Chat session has been restored after page navigation or refresh | |
| restoreTimeout | Chat session restoration attempted was denied after user navigated away from originating website for longer than the time limit: default 60 seconds. | |
| restoreFailed | Could not restore chat session after page navigation or refresh | |
| messageReceived | A new message has been received from the server. Includes text messages, status messages, notices, and other message types | |
| error | An error occurred between the client and the server | (AJAX Response) |
| started | Chat session has successfully started | |
| ended | Chat session has successfully ended | |
| agentTypingStarted | Agents has started typing a new message | |
| agentTypingStopped | Agent has stopped typing | |
| pollingStarted | Chat server automatic polling has started | |
| pollingStopped | Chat server automatic polling has stopped | |
| clientConnected | Indicates the user has been connected to the chat session | {message: (object), agents: (object), numAgentsConnected: (number)} |
| clientDisconnected | Indicates the user has been disconnected form the chat session | {message: (object), agents: (object), numAgentsConnected: (number)} |
| agentConnected | Indicates an agent has connected to the chat | {message: (object), agents: (object), numAgentsConnected: (number)} |
| agentDisconnected | Indicates an agent has disconnected from the chat | {message: (object), agents: (object), numAgentsConnected: (number)} |
| supervisorConnected | Indicates a supervisor has connected to the chat | {message: (object), agents: (object), numAgentsConnected: (number)} |
| supervisorDisconnected | Indicates a supervisor has disconnected from the chat | {message: (object), agents: (object), numAgentsConnected: (number)} |
| clientTypingStarted | The user has started typing. Sends an event to the agent. | |
| clientTypingStopped | After a user stops typing, a countdown begins. When the countdown completes, the typing notification will clear for the agent. |
Comments or questions about this documentation? Contact us for support!
