Contents
Lab Javascript (Web) Sample
You can access this sample through the GMS Service Management UI.
You can download the sample application source code via a zip file:
Genesys Mobile Services JavaScript Sample Source Code
Overview
The Genesys Mobile Services (GMS) Javascript sample illustrates how to implement a Desktop/Mobile browser web application that communicates with GMS and performs supported contact scenarios. It is primarily meant to be used by developers as a reference to build a Javascript-based web application with GMS.
This sample can also be used to test an existing GMS deployment.
Implemented Scenarios
This sample supports the scenarios described in the Callback Scenarios. These scenarios are server-driven, which means that the server instructs the client with the actions needed to carry out the scenario. The client just needs to perform these actions and the follow-up dialog with the server. Therefore, the client is flexible enough to support any scenario that is built using the same kind of actions. The following actions are supported:
- DialNumber - The app makes a phone call when running on a mobile browser.
- ConfirmationDialog - The app displays a message requesting the user to confirm a follow-up action.
- DisplayMenu - The app displays a menu for the user to select an item that may affect how the scenario proceeds.
- StartChat - The app starts a chat conversation. Asynchronous HTTP notifications (CometD messages) are used for receiving Chat Server events.
- get-dialog* - Retrieves the dialog details and displays the dialog to the user. Dialogs are limited to alerts.
This sample also supports the request-interaction scenario, and the chat-interaction scenario.
Push notifications through CometD are supported. Delayed scenarios are supported by using push notifications only; the app will not poll the server to be notified about agent availability.
Prerequisites
In order to use this sample app, you need to have GMS installed and running, and the services that you want to make use of must be deployed.
Running the Sample
- Download the zip file from the above link.
- Extract the zip into the following directory: <gms install folder>/webapps/webcallback.
- Access the app at the following URL: http://<gmshost>:<gmsport>/webcallback/index.html.
- Set the Settings > Contact#.
- Select Scenario and then click the Connect button (located in the top right in the GMS tab of the application).
Notes:
- The CometD client is automatically started when the application loads in the browser.
- Make sure that your URL starts with the value specified in GMS > Server > external_url_base when you access the Service Management UI.
About the Code
The majority of the code is in two files:
- index.html - Controls the presentation aspects of the application, which includes the GMS response handler.
- gms.js - Responsible for interfacing with GMS and as well as managing the CometD connection.
index.html
The following screens are presented to the user and can be displayed by clicking the corresponding tabs.
- GMS - The application home screen showing which GMS scenario can be executed.
- Log - Displays log messages related to client-server communication and application debug messages.
- Chat - Allows exchange of chat messages between client and agent. Notices relating to agent status and connections are also displayed.
- Queue - For delay scenarios, checks the status of the interaction in the queue (when a request has been placed and is waiting for an agent).
- Settings - Application settings can be made on this screen.
gms.js
Two objects are implemented in this file:
- gmsInterface - Allows the creation of GMS callback services and delegates responses to index.html::onResponseRecieved.
- gmsNotificationClient - Responsible for starting the CometD client and connecting to the GMS CometD channel. When the message is received, the callback function index.html::onCometNotification is invoked.
Disclaimer
THIS CODE IS PROVIDED BY GENESYS TELECOMMUNICATIONS LABORATORIES, INC. ("GENESYS") "AS IS" WITHOUT ANY WARRANTY OF ANY KIND. GENESYS HEREBY DISCLAIMS ALL EXPRESS, IMPLIED, OR STATUTORY CONDITIONS, REPRESENTATIONS AND WARRANTIES WITH RESPECT TO THIS CODE (OR ANY PART THEREOF), INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. GENESYS AND ITS SUPPLIERS SHALL NOT BE LIABLE FOR ANY DAMAGE SUFFERED AS A RESULT OF USING THIS CODE. IN NO EVENT SHALL GENESYS AND ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, ECONOMIC, INCIDENTAL, OR SPECIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, ANY LOST REVENUES OR PROFITS).