globalFunction
Genesys() global function
The Genesys()
global function allows you to easily call plugin commands and subscribe to events. For example, you can use it to hide the launcher button in the Launcher plugin and record custom events in the Journey plugin. For a list of the available plugins and their associated commands and events, see Commands and events.
Load the Genesys()
global function
Genesys()
is bundled into our genesys.js
bootstrap file, which you load into your website when you deploy Messenger.
Execution queue
The single snippet provides an execution queue that buffers Genesys()
calls until genesys.js
fully loads and initializes. When it completes initialization, it executes items in the queue in order. This allows for genesys.js
to be loaded asynchronously and gives better flexibility for third-party integrations.
The code for this execution queue is included in the single snippet, so you must call the Genesys()
function only after the snippet has executed, otherwise the queue won't be ready.
Single snippet
The following code creates the Genesys()
queue and injects the genesys.min.js
script to load asynchronously. Genesys()
won't be ready until the file loads and initializes. Without this queue, the integration script after the single snippet throws an error that "Genesys is not defined."
<script type="text/javascript" charset="utf-8">
(function (g, e, n, es, ys) {
g['_genesysJs'] = e; g[e] = g[e] || function () {(g[e].q = g[e].q || []).push(arguments)};
g[e].t = 1 * new Date(); g[e].c = es; ys = document.createElement('script'); ys.async = 1;
ys.src = n; ys.charset = 'utf-8'; document.head.appendChild(ys);
})(window, 'Genesys', 'https://apps.mypurecloud.com/genesys-bootstrap/genesys.min.js', {
deploymentId: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',
environment: 'prod'
});
</script>
The single snippet contains a deploymentId
and environment
values which are unique to your Genesys Cloud organization and are required for Messenger to function properly.
Note: You should not change the values defined within the single snippet.
Genesys Cloud is available across a number of regions and the environment value in the single snippet will match the region where your Genesys Cloud organization is located.
Region | Environment |
US East 1 (Virginia) | prod |
US East 2 (Ohio) | fedramp-use2-core |
US West (Oregon) | prod-usw2 |
Canada (Central) | prod-cac1 |
Europe (Ireland) | prod-euw1 |
Europe (London) | prod-euw2 |
Europe (Frankfurt) | prod-euc1 |
Europe (Zurich) | prod-euc2 |
Asia Pacific (Mumbai) | prod-aps1 |
Asia Pacific (Tokyo) | prod-apne1 |
Asia Pacific (Seoul) | prod-apne2 |
Asia Pacific (Osaka) | prod-apne3 |
Asia Pacific (Sydney) | prod-apse2 |
South America (São Paulo) | prod-sae1 |
Middle East (UAE) | prod-mec1 |
For more information about the regions and API hosts, see Genesys Cloud Regions.
Your integration script
Messenger is comprised of multiple plugins that control specific features of the product. Each plugin has commands and events that can be utilized via the Genesys()
global function. After the single snippet executes, you can use the Genesys()
function to call commands in plugins and subscribe to events while genesys.js
is loaded and initialized asynchronously.
Any usage of the Genesys()
function while genesys.js
is loading and initializing will be queued and executed in order after initialization completes.
For more information about the available plugins, along with their commands and events, see Commands and events.
<script type="text/javascript" charset="utf-8">
Genesys("subscribe", "Launcher.ready" , function(o){
console.log("The queue works!");
});
</script>
Call a command
The Genesys()
function is a multi-purpose function that takes different parameters depending on the value of the first parameter, called the "action".
To call a command, set the action value to "command" and use the following parameters, as necessary.
Data type | Description | Status | Value(s) |
string | action type | required | "command" |
string | command name | required | Follows "PluginName.commandName" format |
object | command options | optional | Any properties supported by the command |
function | promise fulfilled callback | optional | |
function | promise rejected callback | optional |
Genesys("command", "Plugin.commandName", {property: "value"}, function(o){/*fulfilled*/}, function(o){/*rejected*/});
Subscribe to events
To subscribe to events, set the action value to "subscribe" and use the following parameters.
Data type | Description | Status | Value(s) |
string | action type | required | "subscribe" |
string | event name | required | Follows "PluginName.eventName" format |
function | event callback | optional |
Genesys("subscribe", "Plugin.eventName", function(o){/*callback*/});
Enable console logging
You can optionally enable verbose console logging to debug Messenger activity on all of the webpages where you have deployed Messenger.
In the snippet, add a debug: true
line.
<script type="text/javascript" charset="utf-8">
(function (g, e, n, es, ys) {
g['_genesysJs'] = e; g[e] = g[e] | | function () {(g[e].q = g[e].q | | []).push(arguments)};
g[e].t = 1 * new Date(); g[e].c = es; ys = document.createElement('script'); ys.async = 1;
ys.src = n; ys.charset = 'utf-8'; document.head.appendChild(ys);
})(window, 'Genesys', 'https://apps.mypurecloud.com/genesys-bootstrap/genesys.min.js', {
deploymentId: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',
environment: 'prod',
debug: true // optional - Enables Genesys browser console logging
});
</script>