Callback Services API
Getting Started
When you add a callback service, you define a Service Name, which is referred as {callback-execution-name} in this API documentation. Each time that you perform a callback query, you must specify the {callback-execution-name} in the URI parameters.
Accessing your Callback Service
The URLs used by the Callback API are dependent on the execution name of the Callback service that you have just created. Callback services are available at the following URL:
http://<host>:<port>/{base-web-application}/service/callback/{callback-execution-name}
For instance, if you create a callback service named callback-for-mobile, then {callback-execution-name} is callback-for-mobile, its configuration in GMS is located in the service.callback-for-mobile section, and you can access the callback service at the following URL:
http://<host>:<port>/{base-web-application}/service/callback/callback-for-mobile
Overwriting Configuration in Queries
You can create variables in your configuration parameters, then overwrite the current configuration by setting these variables in your queries.
To create a variable, all you need to do is to specify a string matching the following format in your service configuration: $my_variable$.
Then, you can use the parameter my_variable=MYVALUE in your REST queries; any occurrence of $my_variable$ in this service will be replaced with this value.
List of API Queries
The Callback Services API provides the following REST queries:
- Start-Callback–Initiate a Callback request.
- Cancel-Callback–Cancel a Callback request.
- Query-Availability—Get the availability for a new callback request.
- Query-Callback—Query outstanding callbacks by properties.
- ADMIN - Query-Callback—Query outstanding callbacks by queue(s).
Start-Callback
Start-Callback initiates a callback request. It validates the request by doing the following:
- Checks parameters, in general (target queue is valid).
- Checks the customer number against exceptions.
- Checks the time criteria of the request against the business.
- If invalid:
- Returns the appropriate error.
- Sends a reporting event to the GMS data manager indicating that the callback request has been rejected.
- If valid:
- Creates a unique ID for the request.
- Sends a reporting event to the GMS data manager indicating that the callback request has been accepted and started.
This event also indicates the state of the request (immediate or scheduled). - If the request needs to be scheduled for a later date/time, the request and its associated data will be stored in the module persistent data storage.
- If the request can be started now, an ORS session is initiated using the associated SCXML-based service with this particular callback request.
Note: the provisioned data for the execution service to be started will be used as input along with the input parameters from the request itself. - Returns the ID generated for this request.
- If invalid:
Description | Start-Callback | |||
---|---|---|---|---|
Method | POST | |||
URL | http://<host>:<port>/{base-web-application}/service/callback/{callback-execution-name} | |||
Name | Type | Mandatory | Description | |
URI Parameters | ||||
{callback-execution-name} | string | yes | Name of the callback execution service provisioned in GMS. | |
Body (JSON content) | ||||
_customer_number | string | yes | Number to call back.
This parameter can also be replaced by any parameter specified in the option _mandatory_customer_lookup_keys (comma separated list of attributes) that can identify a unique customer. | |
_desired_time | string | no | Desired time to have the callback. Format is ISO 8601 "yyyy-MM-ddTHH:mm:ss.SSSZ" For example: "2013-05-28T15:30:00.000Z" Default is current time.
Note that the Callback is an immediate Callback based on the following rule:
| |
<property> | string | no | Any properties key/values to be attached. Key/Values may be used in Orchestration execution service. Keys without an underscore prefix are User Attached Data. | |
_callback_state | string | no | Forces creation of Callback in a specified state. Important: This is for advanced users that handle Callback life-cycle externally to GMS. By default, the _callback_state value is either QUEUED or SCHEDULED depending if the Callback is processed as immediate or scheduled (respectively). | |
_urs_virtual_queue | string | no | Queue to use for this callback if several virtual queues are used for callback with identical configuration. | |
_request_queue_time_stat | string | no | Queue statistics. For example, "ExpectedWaitTime;Queue;8999@SIP_Server;Environment". Note: If this option is set, it always overwrites the parameter. | |
Response Body (JSON content) | ||||
Name | Type | Mandatory | Description | |
_id | string | yes | The service id for which a successful callback request was registered. |
HTTP code | 200 |
---|---|
HTTP message | OK |
Example Operation
POST http://localhost:8080/genesys/1/service/callback/request-callback
{
"_customer_number": "5115",
"_usr_customer_name": "Bob Markel",
"_usr_reason": "billing question",
"_device_notification_id": "b16416334828b1d26ef14f329628b55b5a8c631d8928a371a5584722dd7fb673",
"_device_os": "comet",
"_desired_time":"2013-06-17T10:25:00.000Z"
}
Result
200 OK { "_id":"a550a12e-ca77-4146-98d0-58960e0939f7" }
The result for this operation is different if immediate/schedule. If immediate, some information may be returned in response along with service_id.
200 OK { "ID": "0", "Action": "ConfirmationDialog", "Text": "You will receive the call shortly", "OkTitle": "Ok", "_id": "361-58ce803e-362c-477f-8ac8-5bbc93f9acc7" }
Cancel-Callback
The Cancel-Callback API cancels a Callback request, by doing the following:
- Validates that the request is still in the queue.
- If not, returns the appropriate error.
- If valid, removes the request from the scheduling queue.
- Checks state of the Callback request:
- If _callback_state=QUEUED, a callback cancel event is submitted to the execution service.
- Callback request is marked _callback_state=COMPLETED with _callback_reason=CANCELLED.
Description | Cancel-Callback | |||
---|---|---|---|---|
Method | DELETE | |||
URL | http://host:port/{base-web-application}/service/callback/{callback-execution-name}/{service_id} | |||
Name | Type | Mandatory | Description | |
URI Parameters | ||||
{service_id} | string | yes | This is the service id returned from the initial start callback response. | |
{callback-execution-name} | string | yes | This is the name of the callback execution service of 'ors' type that is provisioned in GMS. | |
Body (JSON content) | ||||
Response Body (JSON content) | ||||
Name | Type | Mandatory | Description |
HTTP code | 200 |
---|---|
HTTP message | OK |
Example Operation
DELETE http://localhost:8080/genesys/1/service/callback/BasicCallback/a550a12e-ca77-4146-98d0-58960e0939f7 Result 200 OK
DELETE http://localhost:8080/genesys/1/service/callback/BasicCallback/a550a12e-ca77-4146-98d0-58960e0939f7 Result 400 Bad Request { "message": "No such request to cancel : [a550a12e-ca77-4146-98d0-58960e0939f7]", "exception": "com.genesyslab.gsg.services.callback.CallbackException" }
DELETE http://localhost:8080/genesys/1/service/callback/callback-test/361-cf088d4e-88ab-452c-ac1f-39086cc96cbe Result 400 Bad Request { "message": "Request already cancelled or completed : [361-cf088d4e-88ab-452c-ac1f-39086cc96cbe]", "exception": "com.genesyslab.gsg.services.callback.exceptions.CallbackExceptionInvalidOperation" }
Reschedule-Callback
The Reschedule-Callback API changes various input parameters associated with a given callback service. This request will have the callback request id that is to be updated. This API does the following:
- Validates that the request is still in the scheduling queue.
- If not, returns the appropriate error.
- If valid, updates the request in the scheduling queue.
Note: The Reschedule operation is available only for requests where _callback_state=SCHEDULED.
Description | Update-Callback | |||
---|---|---|---|---|
Method | PUT | |||
URL | http://host:port/{base-web-application}/service/callback/{callback-execution-name}/{service_id} | |||
Name | Type | Mandatory | Description | |
URI Parameters | ||||
{service_id} | string | yes | This is the service id returned from initial start callback response. | |
{callback-execution-name} | string | yes | This is the name of the callback execution service of 'ors' type that is provisioned in GMS. | |
Body (JSON content) | ||||
_new_desired_time | string | no | The new time for which to reschedule the callback.
If provided and validated through office-hours, _callback_state will be automatically switched to "scheduled" or "immediate", discarding _callback_state property. | |
_callback_state | string | no | Possible values are:
Note: The _callback_state is incompatible with the _new_desired_time property. | |
<other properties> | any | no | Properties to be updated in request. | |
Response Body (JSON content) | ||||
Name | Type | Mandatory | Description | |
See example. | string | yes |
|
HTTP code | 200 |
---|---|
HTTP message | OK |
Example: Operation Successful
Successful Rescheduling
PUT http://localhost:8080/genesys/1/service/callback/BasicCallback/a550a12e-ca77-4146-98d0-58960e0939f7 { "_new_desired_time":"2013-05-27T15:05:00.000Z" } Result 200 OK
Failed Rescheduling
PUT http://localhost:8080/genesys/1/service/callback/callback-test/361-d61e636da-3109-436c-877e-8d7174277bb9 { "_new_desired_time":"2014-07-22T10:00:00.000Z" } Result 400 Bad Request { "message": "Callback '361-738dadcb-9d20-4557-8e24-fddb82f9c1b8' is no longer scheduled. State=PROCESSING", "exception": "com.genesyslab.gsg.services.callback.exceptions.CallbackExceptionInvalidOperation" }
Example: No Availability
PUT http://localhost:8080/genesys/1/service/callback/BasicCallback/a550a12e-ca77-4146-98d0-58960e0939f7 { "_new_desired_time":"2013-05-27T16:45:00.000Z" } Result 400 Bad Request { "message": "Too many requests at desired time [2013-05-27T16:45:00.000Z, 2013-05-27T16:50:00.000Z]. Proposing time slots.", "exception": "com.genesyslab.gsg.services.callback.CallbackExceptionAvailability", "availability": { "2013-05-27T16:50:00.000Z": 5, "2013-05-27T16:35:00.000Z": 5, "2013-05-27T16:40:00.000Z": 5, "2013-05-27T16:55:00.000Z": 3, "2013-05-27T16:25:00.000Z": 5, "2013-05-27T16:30:00.000Z": 5 } }
Sample operation typicaly performed by ORS execution
PUT http://localhost:8080/genesys/1/service/callback/callback-test/361-738dadcb-9d20-4557-8e24-fddb82f9c1b8 { "_callback_state":"PROCESSING", "_reason":"" } Result 200 OK {}
Query-Callback
The Query-Callback API queries the current set of outstanding Callback services associated with a given property.
Notes:
- Outstanding Callback services are requests where _callback_state is one of the following values: SCHEDULED, QUEUED, ROUTING, PROCESSING, COMPLETED.
- Properties allowing the Callback request trackback are defined as comma-separated keys with service option _customer_lookup_keys.
Description | Query-Callback | |||
---|---|---|---|---|
Method | GET | |||
URL |
| |||
Name | Type | Mandatory | Description | |
URI Parameters | ||||
{callback-execution-name} | string | no since 8.5.101.03 |
This is the name of the callback execution service of 'ors' type that is provisioned in GMS. | |
{property=value} | string | yes | This is a property name used to query the callback.
Several properties may be specified. | |
operand | string | no | Possible values are AND or OR. Default is AND.
When multiple properties are provided, specifies which operation to perform on matched Callback requests:
| |
_callback_state
Since 8.5.101.03 |
string | no |
Specifies a unique state to filter onto. For example:
Important The character "!" is used to negate a case.You can query the following callback states:
| |
_desired_time_from
Since 8.5.101.03 |
string | no |
Specifies ISO timestamps. All callback matching lookup properties and scheduled before this time will be filtered out. | |
_desired_time_to
Since 8.5.101.03 |
string | no |
Specifies ISO timestamps. All callback matching lookup properties and scheduled after this time will be filtered out. (warning)
| |
Body (JSON content) | ||||
Response Body (JSON content) | ||||
Name | Type | Mandatory | Description | |
See example. | string | yes |
|
HTTP code | 200 |
---|---|
HTTP message | OK |
Example Operation
GET http://localhost:8080/genesys/1/service/callback/BasicCallback?_customer_number=555-5461206
Result
200 OK
[
{
"_id": "a550a12e-ca77-4146-98d0-58960e0939f7",
"desired_time": "2013-05-27T15:05:00.000Z",
"_callback_state": "QUEUED",
"_expiration_time": "2014-11-03T18:36:45.000Z",
"_customer_number": "555-5461206",
"url": "/1/service/callback/BasicCallback/a550a12e-ca77-4146-98d0-58960e0939f7"
},
{
"_id": "4a1ea889-1ef7-432d-a543-cff96b4a2daf",
"desired_time": "2013-05-27T15:10:00.000Z",
"_callback_state": "SCHEDULED",
"_expiration_time": "2014-11-03T18:36:45.000Z",
"_customer_number": "555-5461206",
"url": "/1/service/callback/BasicCallback/4a1ea889-1ef7-432d-a543-cff96b4a2daf"
}
]
Query-Availability
Description | Availability REST Request | |||
---|---|---|---|---|
Method | GET | |||
URL | /genesys/1/service/callback/<service-name>/availability | |||
Name | Type | Mandatory | Description | |
URI Parameters | ||||
None. | ||||
Body | ||||
start | date | no | Start date is specified in ISO 8601 format, using UTC as timezone: yyyy-MM-ddTHH:mm:ss.SSSZ. If not specified, it is assumed to be now. | |
timestamp | date | no | Alias to start parameter; kept for compatibility reasons. | |
number-of-days | integer | no | Used as an alternative to the end date. If neither end, nor number-of-days is specified, the end date is assumed to be the same as start date. | |
end | date | no | End date is specified in ISO 8601 format, using UTC as timezone: yyyy-MM-ddTHH:mm:ss.SSSZ. If neither end, nor number-of-days is specified, the end date is assumed to be the same as start date. | |
max-time-slots | integer | no | Maximum number of time slots to be included in the response when the office is open and capacity is above zero. It can be used to improve performance of the query over a lengthy period of time. | |
Response Body | ||||
See example below. |
Request example:
http://localhost:8080/genesys/1/service/callback/Callback_VQ/availability?start=2014-12-03T15:00:00.000Z&number-of-days=2
Response
The Callback controller provides a facet to the availability service, which uses the calendar service underneath. In the same manner as the calendar service takes three non-mandatory input parameters (start, number-of-days, end), the availability service should accept the same parameters and pass them on to the calendar service. The response contains a map of time slots and capacity counters. The slots are ordered in ascending order. Any time slots where capacity is full (for example, zero) are not provided in the response. In a similar way, if the office is closed, those time slots are not provided in the response.
{ // All periods are ordered in ascending time order "2014-10-17T13:00:00.000Z":"5", "2014-10-17T13:10:00.000Z":"4", // there were no agents available between 13:20 and 13:30 UTC, hence the time slot is not reported "2014-10-17T13:30:00.000Z":"5" }
ADMIN - Query-Callback
The Query-Callback API queries the current set of outstanding Callback services in given queue(s).
Description | Query-Callback | |||
---|---|---|---|---|
Method | GET | |||
URL | http://host:port/{base-web-application}/admin/callback/queues?target={target_name}&end_time={iso_end_time} | |||
Name | Type | Mandatory | Description | |
URI Parameters | ||||
{iso_end_time} | string | no | This is the maximum time for which to query callback requests.
If not specified, requests that are due in next 24 hours are returned. The format is ISO 8601 "yyyy-MM-ddTHH:mm:ss.SSSZ". For example: "2013-05-28T15:30:00.000Z" | |
{target} | string | no | This is the name of a callback execution service. If not specified, the queues for all services are returned. For example: BasicCallback. | |
{max} | integer | no | This is maximum number of requests to return for each queue.
If not specified, 500 maximum requests per queue are returned. | |
Body (JSON content) | ||||
Response Body (JSON content) | ||||
Name | Type | Mandatory | Description | |
See example. | string | yes | If accepted, a tree list of target queues and requests. |
HTTP code | 200 |
---|---|
HTTP message | OK |
Example Operation
GET http://localhost:8080/genesys/1/admin/callback/queues
Result
200 OK { "BasicCallback": [ { "_customer_number": "654321", "_callback_state": "PROCESSING", "_desired_time": "2013-06-07T16:25:00.000Z", "_id": "fd30abb97bd04885b544893276fb534b", "url": "/1/service/callback/BasicCallback/fd30abb97bd04885b544893276fb534b" } ], "AdvancedCallback": [ { "_customer_number": "654321", "_callback_state": "QUEUED", "_desired_time": "2013-06-07T16:35:00.000Z", "_id": "07d2ddd506f04b4ba91aba59c4fa8871", "url": "/1/service/callback/AdvancedCallback/07d2ddd506f04b4ba91aba59c4fa8871" }, { "_customer_number": "654321", "_callback_state": "SCHEDULED", "_desired_time": "2013-06-07T16:45:00.000Z", "_id": "8f68d4969d904d039ccf0101fac39283", "url": "/1/service/callback/AdvancedCallback/8f68d4969d904d039ccf0101fac39283" } ] }
Sample Errors
Number Exceptions
{ "message": "Customer Number [12345] is not allowed. Check option 'exceptions' : details={Callback_exceptions=exception2}", "exception": "com.genesyslab.gsg.services.callback.CallbackServiceException" }
Business Hours Exceptions
{ "message": "{"status":"closed","reason":"closed_day_of_week"}", "exception": "com.genesyslab.gsg.services.callback.CallbackServiceException" }
{ "message": "{"status":"closed","reason":"closed_no_match"}", "exception": "com.genesyslab.gsg.services.callback.CallbackServiceException" }
Queue Full Exceptions
{ "message": "Too many requests around this desired time : 2013-05-24T18:03:29.952Z", "exception": "com.genesyslab.gsg.services.callback.CallbackServiceException" }
{ "message": "Too many requests at desired time [2013-05-28T15:30:00.000Z, 2013-05-28T15:45:00.000Z]. Proposing time slots.", "exception": "com.genesyslab.gsg.services.callback.CallbackAvailabilityException", "availability": { "2013-05-28T16:00:00.000Z": 4, "2013-05-28T16:45:00.000Z": 5, "2013-05-28T15:00:00.000Z": 5, "2013-05-28T15:45:00.000Z": 5, "2013-05-28T15:15:00.000Z": 5, "2013-05-28T16:30:00.000Z": 5, "2013-05-28T16:15:00.000Z": 5 } }