Contents
API Commands
open
Opens the WebChat UI.
Example
oWebChat.command('WebChat.open',{
userData: {},
form: {
autoSubmit: false,
firstname: 'John',
lastname: 'Smith',
email: 'John@mail.com',
subject: 'Customer Satisfaction'
}
}).done(function(e){
// WebChat opens successfully
}).fail(function(e){
// WebChat isn't open or no active chat session
});
Options
| Option | Type | Description |
|---|---|---|
| userData | object | Object containing arbitrary data that gets sent to the server. Overrides userData set in the webchat configuration object. |
| form | object | Object containing form data to prefill in the chat entry form and optionally auto-submit the form. |
| form.autoSubmit | boolean | Automatically submit the form. Useful for bypassing the entry form step. |
| form.firstname | string | Value for the first name entry field. |
| form.lastname | string | Value for the last name entry field. |
| form.email | string | Value for the email entry field. |
| form.subject | string | Value for the subject entry field. |
Resolutions
| Status | When | Returns |
|---|---|---|
| resolved | When WebChat is successfully opened | n/a |
| rejected | When WebChat is already open | 'already opened' |
close
Closes the WebChat UI.
Example
oWebChat.command('WebChat.close').done(function(e){
// WebChat closes successfully
}).fail(function(e){
// WebChat is already closed or no active chat session
});
Resolutions
| Status | When | Returns |
|---|---|---|
| resolved | When WebChat is successfully closed | n/a |
| rejected | When WebChat is already closed | 'already closed' |
configure
Modify configuration options for WebChat. See configuration page for WebChat.
Example
oWebChat.command('WebChat.configure',{
chatButton:{
enabled: false,
openDelay: 1000,
template: tplChatButton,
effect: 'fade',
effectDuration: 1000,
hideDuringInvite: true
},
autoInvite:{
enabled: true,
timeToInviteSeconds: 1000,
inviteTimeoutSeconds: 1000
},
emojis: true,
actionsMenu: true
}).done(function(e){
// WebChat configured successfully
}).fail(function(e){
// WebChat wasn't configured properly
});
Options
| Option | Type | Description |
|---|---|---|
| chatButton.enabled | boolean | Enable/disable chat button on screen. |
| chatButton.openDelay | number | Number of milliseconds before displaying chat button on screen. |
| chatButton.template | string | Custom HTML string template for chat button. |
| chatButton.effect | string | Type of animation effect when revealing chat button. 'slide' or 'fade'. |
| chatButton.effectDuration | number | Length of animation effect in milliseconds. |
| chatButton.hideDuringInvite | boolean | When auto-invite feature is activated, hide the chat button. When invite is dismissed, reveal the chat button again. |
| autoInvite.enabled | boolean | Enable/disable auto-invite feature. Automatically invites user to chat after user idles on page for preset time. |
| autoInvite.timeToInviteSeconds | number | Number of seconds of idle time before inviting customer to chat. |
| autoInvite.inviteTimeoutSeconds | number | Number of seconds to wait, after showing invite, before closing chat invite. |
| emojis | boolean | Enable/disable Emoji menu inside chat message input. |
| actionsMenu | boolean | Enable/disable actions menu next to chat message input. |
Resolutions
| Status | When | Returns |
|---|---|---|
| resolved | When configuration options are provided and set | n/a |
| rejected | When no configuration options are provided | 'Invalid configuration' |
minimize
Minimize or unminimize WebChat UI.
Example
oWebChat.command('WebChat.minimize',{minimized: false}).done(function(e){
// WebChat minimized successfully
}).fail(function(e){
// WebChat ignores command
});
Options
| Option | Type | Description |
|---|---|---|
| minimized | boolean | Rather than toggling the current minimized state you can specify the minified state directly: true = minimized, false = uniminimized. |
Resolutions
| Status | When | Returns |
|---|---|---|
| resolved | Always | n/a |
| rejected | Never | 'Invalid configuration' |
endChat
Starts the 'end chat' procedure. User may be prompted to confirm.
Example
oWebChat.command('WebChat.endChat').done(function(e){
// WebChat ended a chat successfully
}).fail(function(e){
// WebChat has no active chat session
});
Resolutions
| Status | When | Returns |
|---|---|---|
| resolved | When there is an active chat session to end | n/a |
| rejected | When there is no active chat session to end | 'there is no active chat session to end' |
invite
Show an invitation to chat using the Toaster popup element. Text shown in invitation can be edited in the localization file.
Example
oWebChat.command('WebChat.invite').done(function(e){
// WebChat invited successfully
}).fail(function(e){
// WebChat is already open and will be ignored
});
Resolutions
| Status | When | Returns |
|---|---|---|
| resolved | When WebChat is closed and the toast element is created successfully | n/a |
| rejected | When WebChat is already open (prevents inviting a user that is already in a chat). | 'Chat is already open. Ignoring invite command.' |
reInvite
When an active chat session is unable to restore, this invitation will offer the user to start a new chat. Text shown in invitation can be edited in the localization file.
Example
oWebChat.command('WebChat.reInvite').done(function(e){
// WebChat reinvited successfully
}).fail(function(e){
// WebChat is already open and will be ignored
});
Resolutions
| Status | When | Returns |
|---|---|---|
| resolved | When WebChat is closed, the config item 'webchat.inviteOnRestoreTimeout' is set, and the toast element is created successfully | n/a |
| rejected | When WebChat is already open. Prevents inviting a user that is already in a chat | 'Chat is already open. Ignoring invite command.' |
injectMessage
Inject a custom message into the chat transcript. Useful for extending WebChat functionality with other Genesys products.
Example
oWebChat.command('WebChat.injectMessage',{
type: 'text',
name: 'person',
text:'hello',
custom: false
}).done(function(e){
// WebChat injected a message successfully
// e.data == The message HTML reference (jQuery wrapped set)
}).fail(function(e){
// WebChat isn't open or no actvite chat
});
Options
| Option | Type | Description |
|---|---|---|
| type | string | Switch the rendering type of the injected message between text and html. |
| name | string | Specify a name label for the message to identify what service or widget has injected the message. |
| text | string | The content of the message. Either plain text or HTML. |
| custom | boolean | If set to true, the default message template will not be used, allowing you to inject a highly customized HTML block unconstrained by the normal message template. |
Resolutions
| Status | When | Returns |
|---|---|---|
| resolved | When WebChat is open and there is an active chat session | An HTML reference (jQuery wrapped set) to the new injected message. |
| rejected | When WebChat is not open and/or there is no active chat session | 'No active chat session.' |
showChatButton
Makes the standalone chat button visible on the screen using either the default template and CSS or customer-defined ones.
Example
oWebChat.command('WebChat.showChatButton',{
openDelay: 1000,
duration: 1500
}).done(function(e){
// WebChat shows chat button successfully
}).fail(function(e){
// WebChat button is already visisible, side bar is active and overrides the chat button, or chat button is disabled in configuration
});
Options
| Option | Type | Description |
|---|---|---|
| openDelay | number | Duration in milliseconds to delay showing the chat buton on the page. |
| duration | number | Duration in milliseconds for the show and hide animation. |
Resolutions
| Status | When | Returns |
|---|---|---|
| resolved | When the chat button is enabled in the configuration, is currently not visible, and the SideBar plugin is not initialized | n/a |
| rejected | When the chat button is not enabled in the configuration, or it's already visible, or the SideBar plugin is initialized | 'Chat button is already visible. Ignoring command.' |
| rejected | When the sidebar plugin is active the standalone chat button will be disabled automatically | 'SideBar is active and overrides the default chat button' |
hideChatButton
Hides the standalone chat button.
Example
oWebChat.command('WebChat.hideChatButton',{duration: 1500}),done(function(e){
// WebChat hid chat button successfully
}).fail(function(e){
// WebChat button is already hidden
});
Options
| Option | Type | Description |
|---|---|---|
| duration | number | Duration in milliseconds for the show and hide animation. |
Resolutions
| Status | When | Returns |
|---|---|---|
| resolved | When the chat button is currently visible | n/a |
| rejected | When the chat button is already hidden | 'Chat button is already hidden. Ignoring command.' |
registerPreProcessor
Allows you to register a function that receives the message JSON, allowing you to manipulate the values before it is rendered in the transcript.
Example
oWebChat.command('WebChat.registerPreProcessor',{preprocessor: exampleFunction}).done(function(e){
// WebChat registered preprocessor function
// e.data == function that was registered
}).fail(function(e){
// WebChat is not currently open
});
Options
| Option | Type | Description |
|---|---|---|
| preprocessor | function | The preprocessor function you want to register. |
Resolutions
| Status | When | Returns |
|---|---|---|
| resolved | When a valid preprocessor function is provided and is registered. | The registered preprocessor function. |
| rejected | When an invalid preprocessor function is provided. | No preprocessor function provided. Type provided was '<DATATYPE>'. |
showOverlay
A slide-down overlay the opens over WebChat's content. You can fill this overlay with content such as disclaimers, articles, and other information.
Example
oWebChat.command('WebChat.showOverlay',{
html: tplOverlay,
hideFooter: false
}).done(function(e){
// WebChat successfully shows overlay
}).fail(function(e){
// WebChat isn't open
});
Options
| Option | Type | Description |
|---|---|---|
| html | string or HTML reference | The HTML content you want to display in the overlay. |
| hideFooter | boolean | Normally the overlay appears between the titlebar and footer bar. Set this to true to have the overlay overlap the footer to gain a bit more vertical space. This should only be used in special cases. For general use, don't set this value. |
Resolutions
| Status | When | Returns |
|---|---|---|
| resolved | When WebChat is open and the overlay opens. | |
| rejected | When WebChat is not currently open. | WebChat is not currently open. Ignoring command. |
hideOverlay
Hides the slide-down overlay.
Example
oWebChat.command('WebChat.hideOverlay').done(function(e){
// WebChat hid overlay successfully
}).fail(function(e){
// WebChat isn't open
});
Resolutions
| Status | When | Returns |
|---|---|---|
| resolved | When WebChat is open and the overlay closes. | |
| rejected | When WebChat is not currently open. | WebChat is not currently open. Ignoring command. |
