Jump to: navigation, search

API Commands

Once you've registered your own plugin on the bus, you can call commands on other registered plugins. Below we'll quickly register a new plugin on the bus using the global bus object.

Important
The global bus object is a debug tool. When implementing Widgets on your own site, do not use the global bus object to register your custom plugins. Instead, see Widgets Extensions for more information about extending Genesys Widgets.


var oMyPlugin = window._genesys.widgets.bus.registerPlugin('MyPlugin');

oMyPlugin.command('WebChat.open');

configure

Internal use only. The main App plugin shares configuration settings to widgets using each widget’s configure command. The configure command can only be called once at startup. Calling configure again after startup may result in unpredictable behavior.

open

Opens the WebChat UI.

Example

oMyPlugin.command('WebChat.open', {

	userData: {},
	form: {

		autoSubmit: false,
		firstname: 'John',
		lastname: 'Smith',
		email: 'John@mail.com',
		subject: 'Customer Satisfaction'
	},
	formJSON: {...}, 
	markdown: false

}).done(function(e){

	// WebChat opened successfully

}).fail(function(e){

	// WebChat isn't open or no active chat session
});


Options

Option Type Description Introduced / Updated
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.
formJSON object An object containing a custom registration form definition. See Customizable Chat Registration Form.
userData object Object containing arbitrary data that gets sent to the server. Overrides userData set in the webchat configuration object.
async boolean Starts a new chat either in asynchronous or normal mode based on the boolean value. Note that unless async static configuration is defined, a chat in normal mode will start automatically. 9.0.002.06
markdown boolean The markdown feature for chat messages. 9.0.014.02
id string A Unique identifier of a chat session that helps to identify the instance of that session and its associated events. A random value is automatically generated and assigned when no value is passed explicitly. 9.0.014.09


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

oMyPlugin.command('WebChat.close').done(function(e){

	// WebChat closed 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'

minimize

Minimize or unminimize WebChat UI.

Example

oMyPlugin.command('WebChat.minimize').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

oMyPlugin.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

oMyPlugin.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

oMyPlugin.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

oMyPlugin.command('WebChat.injectMessage', {

	type: 'text',
	name: 'person',
	text: 'hello',
	custom: false,
	bubble:{

		fill: '#00FF00',
		radius: '4px',
		time: false,
		name: false,
		direction: 'right',
		avatar:{

			custom: '<div>word</div>',
			icon: 'email'
		}
	}

}).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 active chat
});


Options

Option Type Description Accepted Values
type string Switch the rendering type of the injected message between text and html. text, html
name string Specify a name label for the message to identify what service or widget has injected the message. n/a
text string The content of the message. Either plain text or HTML. n/a
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. true, false
bubble.fill string of valid CSS color value The content of the message. Either plain text or HTML. n/a
bubble.radius string of valid CSS border radius vale The border radius you'd like for the bubble. n/a
bubble.time boolean If you'd like to show the timestamp for the bubble. true, false
bubble.name boolean If you'd like to show the name for the bubble. true, false
bubble.direction string Which direction you want the message bubble to come from. left, right, none
bubble.avatar.custom string or HTML reference Change the content of the html that would be the avatar for the chat bubble. n/a
bubble.avatar.icon class name Generated common library provided for icon name. n/a


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 was no active chat session 'No chat session to inject into'

showChatButton

Makes the standalone chat button visible on the screen using either the default template and CSS or customer-defined ones.

Example

oMyPlugin.command('WebChat.showChatButton', {

	openDelay: 1000,
	duration: 1500

}).done(function(e){

	// WebChat shows chat button successfully

}).fail(function(e){

	// WebChat button is already visible or chat button is disabled in configuration
});


Options

Option Type Description
openDelay number Duration in milliseconds to delay showing the chat button 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 and is currently not visible. n/a
rejected When the chat button is either not enabled in the configuration, or it's already visible. 'Chat button is not enabled in the configuration, or already visible. Ignoring command.'

hideChatButton

Hides the standalone chat button.

Example

oMyPlugin.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.'

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

oMyPlugin.command('WebChat.showOverlay', {

	html: '<div id='cx_chat_information'>Example text</div>',
	hideFooter: false

}).done(function(e){

	// WebChat successfully shows overlay

}).fail(function(e){

	// WebChat isn't open
});


Options

Option Type Description Accepted Values
html string or HTML reference The HTML content you want to display in the overlay.
Important
The id attribute value of the HTML content can be set to cx_chat_information. This supports a screen reader's ability to announce the overlay's content to the user, as recommended by WCAG.
n/a
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. true, false


Resolutions

Status When Returns
resolved When WebChat is open and the overlay opens. n/a
rejected When WebChat is not currently open. WebChat is not currently open. Ignoring command.

hideOverlay

Hides the slide-down overlay.

Example

oMyPlugin.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. n/a
rejected When WebChat is not currently open. WebChat is not currently open. Ignoring command.
This page was last edited on November 12, 2021, at 15:11.
Comments or questions about this documentation? Contact us for support!