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('SendMessage.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.

Example

oMyPlugin.command('SendMessageService.configure', {

	apikey: '123456',
	dataURL: 'http://localhost:8080/foo/mygms',
	ajaxTimeout: 10000,
	userData: {}

}).done(function(e){

	// SendMessageService configured successfully

}).fail(function(e){

	// SendMessageService failed to configure properly
});


Options

Option Type Description
apikey string Apigee Proxy secure token
dataURL URL String URL of GMS server
ajaxTimeout number Number of milliseconds to wait before AJAX timeout
userData object Arbitrary JSON data to attach to the message.


Resolutions

Status When Returns
resolved When configuration options are provided and set n/a
rejected When no configuration options are provided 'Invalid configuration'

open

opens the send message widget UI.

Example

oMyPlugin.command('SendMessage.open', {

	text: 'To whom it may concern.....',
	userData: {},
	form: {

		autoSubmit: false,
		firstname: 'John',
		lastname: 'Smith',
		email: 'John@mail.com',
		subject: 'Customer Satisfaction',
		messagebody: 'I am truly satisfied!'
	}

}).done(function(e){

	// SendMessage opens successfully

}).fail(function(e){

	// SendMessage 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 sendmessage configuration object.
form object Object containing form data to prefill in the send message form and optionally auto-submit the form.
form.autoSubmit boolean Automatically submit the form and send an email with prefilled content.
form.validation boolean Enables/Disables validating the form data while submitting. By default, its enabled.
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.
text string value for the email body text content entry field


Resolutions

Status When Returns
resolved When Send Message is successfully opened n/a
rejected When Send Message is already open 'Already opened'

close

Closes the Send Message UI.

Example

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

	// SendMessage closed successfully

}).fail(function(e){

	// SendMessage failed to close
});


Resolutions

Status When Returns
resolved When Send Message is successfully closed n/a
rejected When Send Message is already closed 'already closed'

minimize

Minimize or Unminimize Send Message UI.

Example

oMyPlugin.command('SendMessage.minimize').done(function(e){

	// SendMessage minimized successfully

}).fail(function(e){

	// SendMessage ignores command
});


Resolutions

Status When Returns
resolved Always n/a
rejected Never n/a

showSendMessageButton

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

Example

oMyPlugin.command('SendMessage.showSendMessageButton', {

	openDelay: 1000,
	duration: 1500

}).done(function(e){

	// SendMessage shows send message button successfully

}).fail(function(e){

	// SendMessage button is already visisible, side bar is active and overrides the send message button, or chat button is disabled in configuration
});


Options

Option Type Description
openDelay number Duration in milliseconds to delay showing the send message button on the page.
duration number Duration in milliseconds for the show and hide animation.


Resolutions

Status When Returns
resolved When the Send Message button is enabled in the configuration, is currently not visible, and the SideBar plugin is not initialized n/a
rejected When the Send Message button is not enabled in the configuration, or it's already visible, or the SideBar plugin is initialized 'Send Message button is already visible. Ignoring command.'
rejected When the SideBar plugin is active the standalone Send Message button will be disabled automatically 'SideBar is active and overrides the default Send Message button'

hideSendMessageButton

Hides the standalone Send Message button.

Example

oMyPlugin.command('SendMessage.hideSendMessageButton', {

	duration: 1000

}).done(function(e){

	// SendMessage shows send message button successfully

}).fail(function(e){

	// SendMessage button is already visisible, side bar is active and overrides the send message button, or chat button is disabled in configuration
});


Options

Option Type Description
duration number Duration in milliseconds for the show and hide animation


Resolutions

Status When Returns
resolved When the send message button is currently visible n/a
rejected When the send message button is already hidden 'Send Message button is already hidden. Ignoring command.'

submit

The user entered form data and attached files are submitted

Example

oMyPlugin.command('SendMessage.submit').done(function(e){

	// SendMessage submitted form successfully

}).fail(function(e){

	// SendMessage failed to submit form
});


Resolutions

Status When Returns
resolved When Send Message form is submitted successfully n/a
rejected When form submit fails 'No form data found'
This page was last edited on December 11, 2017, at 16:08.
Comments or questions about this documentation? Contact us for support!