Jump to: navigation, search

Notification Service REST API

Description

The Notification Service REST API is a REST-based API that allows you to keep users of your website engaged and informed. You can reach your entire user base quickly and effectively with notifications that are delivered to your web pages. The Notification Service is responsible for delivering the push messages (events) to the Browser Tier. On the Browser Tier, each message is handled by the Notification Agent. The Notification Agent provides a list of predefined messages that can be used in engagement scenarios. Each message uses the "gpe." prefix in the channel name.

The Notification Service REST API is currently accessed through a single method that delivers notifications based on the visit ID.

Notify by Visit ID

Description

This method performs an engagement notification through the Frontend Server by visit ID.

Request

Method POST
Body JSON array of Notification Messages
URL http://<frontend_host:frontend_port>/frontend/data/notification/notify/{visitId}

The HTTPS schema is also allowed, if configured.

Parameters
Name Value Mandatory Description
visitId String yes The visit ID.

Response

Response

Standard HTTP Responses

Response Type none

Example

Request

curl -X POST \
  -H "Content-Type: application/json" \
  -d '[{"page": "654E0122924F42EA82B5C581A394555D", "channel": "gpe.appendContent", 
       "data": { "url": "http://www.genesys.com/invite.html", "method": "GET", "container": "body" }}]' \
  http://198.51.100.12:9081/frontend/data/notification/notify/654E0122924F42EA82B5C581A394555D

Notification Messages

The notification request body is represented by an array of JSON objects, one object for each notification message:

[
    {
        // message 1
    },
    {
        // message 2
    },
    ...
]

Message Structure

Notification messages should follow this format:

{
   "page":"yyy",
   "channel":"any-string",
   "data":{
      "someKey":"someValue"
      ...
   }
}
Option Type Mandatory Default Value Description
page String yes undefined The page attribute can have the following values:
  • page ID — The notification message is only received by the page with the unique page ID.
  • all — The notification message is received by all pages.
channel string yes undefined The channel name. See Standard Messages for details.
data object no undefined Channel-specific data. See Standard Messages for details.

Standard Messages

The following messages are standard in Genesys Web Engagement.

gpe.appendContent

With this message, you can append content retrieved by url to the container element.

Options

Option Type Mandatory Default Value Description
url string yes undefined The path of the resource to load. This option can have either an absolute (http://www.genesys.com/invite.html) or relative value (/invite.html). Note: The relative value is relative to the Frontend Server.
method string no "JSONP" Specifies the type of request to make:
  • GET — You should only use the GET method if the resource is located on the same server, in order to avoid issues with cross-origin resource sharing.
  • JSONP — For the JSONP method, the server you point to in the url option must support the JSONP protocol.
container string no "body" The jQuery selector for the loaded content container. The loaded content is appended to the current element.

Example

The following message uses the AJAX GET request to load data from the server.

{
    "page": "654E0122924F42EA82B5C581A394555D",
    "channel": "gpe.appendContent",
    "data": {
        "url": "http://www.genesys.com/invite.html",
        "method": "GET",
        "container": "body"
    }
}

gpe.setVariable

You can use this message to set the variable on the page in the window context.

Options

Option Type Mandatory Default Value Description
variable string yes undefined The variable name.
value string yes undefined The variable value.

Example

This example sets the variable window['service.data'] to the object { 'name': 'Pat', 'message': 'Hello world!' }.

{
    "page": "654E0122924F42EA82B5C581A394555D",
    "channel": "gpe.setVariable",
    "data": {
        "variable": "serviceData",
        "value": {
            "name": "Pat",
            "message": "Hello world!"
        }
    }
}

gpe.callFunction

This message calls the corresponding function on the page.

Options

Option Type Mandatory Default Value Description
function string yes undefined The name of the function. The name can contain the namespace of the function. For example, com.service.alert.
arguments array no undefined The arguments to pass to the function. This should always be an array.

Example

This example calls the window.reactToServerMessage('Hello world!', 1) function.

{
  "page": "654E0122924F42EA82B5C581A394555D",
  "channel": "gpe.callFunction",
  "data": {
    "function": "reactToServerMessage",
    "arguments": ["Hello world!", 1]
  }
}

Using the API to Customize Widgets

You can also use the Notification Service REST API to customize the out-of-the-box Genesys Web Engagement invitation widgets. See the following sections for details:

Customizing the Default Chat Invitation Message

The default chat invitation message is a JSON object that is sent by Orchestration Server to the browser. The default chat invitation is represented by two serial messages: gpe.setVariable and gpe.appendContent.

[
   {
      "page":"654E0122924F42EA82B5C581A394555D",
      "channel":"gpe.setVariable",
      "data":{
         "variable":"com.genesyslab.gpe.invite.data",
         "value": {
            "type":"chat",
            "subject":"Chat",
            "message":"Good evening! Would you like some help with the selection? Our technical experts are available to answer questions.",
            "acceptBtnCaption":"Chat",
            "cancelBtnCaption":"No Thanks",
            "inviteTimeout":30,  
            "modal":false,
            "chatOptions": { 
               "serverUrl": "http://demosrv.genesyslab.com:9081/backend/cometd",
               "widgetUrl": "/frontend/resources/chatWidget.html",
               "registration":true,  
               "embedded": false,
               "userData": {
                  "visitID":"3ea3efab-ca33-4383-acbd-90720db72288"
               }
            }
         }
      }
   },
   {
      "page":"654E0122924F42EA82B5C581A394555D",
      "channel": "gpe.appendContent",
      "data": {
         "url": "/frontend/resources/invite.html",        
      }
   }
]

You can use the Notification Service REST API to modify the default chat invitation, which uses gpe.setVariable to set the com.genesyslab.gpe.invite.data variable to a list of options. You can update these options to customize the chat invitation. See the table below for details.

Field Type Mandatory Default Value Description
type string yes undefined The type of engagement ("chat" or "callback").
subject string no "Chat", if the type is set to "chat". The invitation widget title.
message string no "Hello! Would you like some help with the selection? Our technical experts are available to answer questions." The main message in the invitation widget.
acceptBtnCaption string no "Chat", if the type is set to "chat". The title of the accept invitation button.
cancelBtnCaption string no "No Thanks" The title of the cancel invitation button.
inviteTimeout Integer no 30 The timeout (in seconds) for the invitation widget. After this time interval, the invitation widget is automatically closed.
modal Boolean no false Specifies whether to show the invitation widget as a modal dialog.
chatOptions object yes undefined This object is passed to the chat application in the startChat method. See Chat JS Application API for details.

Customizing the Default Callback Invitation Message

The default callback invitation message is a JSON object that is sent by Orchestration Server to the browser. The default callback invitation is represented by two serial messages: gpe.setVariable and gpe.appendContent.

[
   {
      "page":"654E0122924F42EA82B5C581A394555D",
      "channel":"gpe.setVariable",
      "data":{
         "variable":"com.genesyslab.gpe.invite.data",
         "value": {
            "type":"callback",
            "subject":"Voice", 
            "message":"Good evening! Would you like some help with the selection? Our technical experts are available to answer questions.",
            "acceptBtnCaption":"Call Me",
            "cancelBtnCaption":"No Thanks",
            "inviteTimeout":30,
            "modal":false,
            "callbackOptions": {         
               "callbackUrl":"http://demosrv.genesyslab.com:9081/backend",
               "widgetUrl":"/frontend/resources/callback.html",              
            }
         }
      }
   },
   {
      "page":"654E0122924F42EA82B5C581A394555D",
      "channel": "gpe.appendContent",
      "data": {
         "url": "/frontend/resources/invite.html",       
      }
   }
]

You can use the Notification Service REST API to modify the default callback invitation, which uses gpe.setVariable to set the com.genesyslab.gpe.invite.data variable to a list of options. You can update these options to customize the callback invitation. See the table below for details.

Option Type Mandatory Default Value Description
type string yes undefined The type of engagement ("chat" or "callback").
subject string no "Callback", if the type is set to "callback". The invitation widget title.
message string no "Hello! Would you like some help with the selection? Our technical experts are available to answer questions." The main message in the invitation widget.
acceptBtnCaption string no "Callback", if the type is set to "callback". The title of the accept invitation button.
cancelBtnCaption string no "No Thanks" The title of the cancel invitation button.
inviteTimeout Integer no 30 The timeout (in seconds) for the invitation widget. After this time interval, the invitation widget is automatically closed.
modal Boolean no false Specifies whether to show the invitation widget as a modal dialog.
callbackOptions object yes undefined The configuration options for the callback widget.
callbackUrl string yes undefined The URL of the callback server. For instance, 198.51.100.12:9081/backend
widgetUrl string yes undefined The URL of the callback server. For instance, 198.51.100.12:8081/resources/callback.html

Customizing the Default Ads Message

You can use the gpe.appendContent message to load the ads.html file.

[
   {
      "page": "654E0122924F42EA82B5C581A394555D",
      "channel": "gpe.appendContent",
      "data": {
         "url": "/frontend/resources/ads.html"        
      }
   }
]
This page was last edited on July 22, 2014, at 12:11.
Comments or questions about this documentation? Contact us for support!