NAV Navigation
Shell Node.js HTTP

Alvaria Public Cloud Messaging (Chat/SMS) REST API v2.0.1

Scroll down for code samples, example requests and responses. Select a language for code samples from the tabs above or the mobile navigation menu.

Overview

The Alvaria Public Cloud™ Messaging (Chat/SMS) REST APIs enable a custom agent application to send text and URLs using a current chat or SMS interaction. Please note that the group of scopes most likely needed when you create a custom agent interface are engagementcenterapi, provisioningapi, messagingapi, outreachapi and streamingapi.

Follow this link if you would like to see the events generated by sending these requests.

Base URLs:

License: License: Creative Commons Attribution 4.0 International Public License

Authentication

Scope Scope Description
messagingapi manage access to engagement center

Users

User Send Text

Code samples

# You can also use wget
curl -X POST https://orgId.via.aspect-cloud.net/via/v2/organizations/{orgId}/messaging/users/{userId}/sendText \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Authorization: string' \
  -H 'x-api-key: string' \
  -H 'via-client-sessionid: string'

const fetch = require('node-fetch');
const inputBody = {
  "interactionId": "4321",
  "entityName": "contactCenterAgent",
  "entityType": "Agent",
  "text": "Hi this is an example of a text string."
};
const headers = {
  'Content-Type':'application/json',
  'Accept':'application/json',
  'Authorization':'string',
  'x-api-key':'string',
  'via-client-sessionid':'string'
};

fetch('https://orgId.via.aspect-cloud.net/via/v2/organizations/{orgId}/messaging/users/{userId}/sendText',
{
  method: 'POST',
  body: JSON.stringify(inputBody),
  headers: headers
})
.then(function(res) {
    return res.json();
}).then(function(body) {
    console.log(body);
});

POST https://orgId.via.aspect-cloud.net/via/v2/organizations/{orgId}/messaging/users/{userId}/sendText HTTP/1.1
Host: orgid.via.aspect-cloud.net
Content-Type: application/json
Accept: application/json
Authorization: string
x-api-key: string
via-client-sessionid: string

POST /via/v2/organizations/{orgId}/messaging/users/{userId}/sendText

This sends a request to the Messaging subsystem containing text on an interaction.

Body parameter

{
  "interactionId": "4321",
  "entityName": "contactCenterAgent",
  "entityType": "Agent",
  "text": "Hi this is an example of a text string."
}

Parameters

Name In Type Required Description
orgId path string true Name of a customer organization
Authorization header string true Authentication token with the value: 'Bearer {accessToken}', where {accessToken} was returned from a call to the authorization endpoint.
x-api-key header string true Alvaria-provided value used to track API endpoint usage
via-client-sessionid header string true Identifier representing a long-lived HTTP interchange between Alvaria™ Cloud and an entity when the entity is a contact, external client application, or authenticated user. This interchange is called the streaming session. Streaming sessions are used for operations such as exchanging text messages and retrieving events related to user activity.
userId path string true Alvaria-generated unique identifier for a user instance that can be retrieved prior to use from the provisioning rest API. The url is /via/v2/organizations/{orgId}/provisioning/users.
body body SendTextParmsSchema true Send Text information

Example responses

400 Response

{
  "code": 404,
  "message": "not found",
  "errors": [
    {
      "scope": "scope",
      "reason": "reason",
      "message": "message"
    }
  ]
}

Responses

Status Meaning Description Schema
202 Accepted Successful response None
400 Bad Request Bad Request ErrorResponse
401 Unauthorized Unauthorized None
404 Not Found Not Found ErrorResponse
405 Method Not Allowed Method Not Allowed ErrorResponse
410 Gone Gone ErrorResponse
422 Unprocessable Entity Cannot Process Entity ErrorResponse
429 Too Many Requests Too Many Requests ErrorResponse
500 Internal Server Error Internal server error ErrorResponse
503 Service Unavailable Service Unavailable ErrorResponse

User Send Notification state

Code samples

# You can also use wget
curl -X POST https://orgId.via.aspect-cloud.net/via/v2/organizations/{orgId}/messaging/users/{userId}/notification \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Authorization: string' \
  -H 'x-api-key: string' \
  -H 'via-client-sessionid: string'

const fetch = require('node-fetch');
const inputBody = {
  "interactionId": "4321",
  "entityName": "contactCenterAgent",
  "entityType": "Agent",
  "state": "composing",
  "expiresAfterSeconds": 10
};
const headers = {
  'Content-Type':'application/json',
  'Accept':'application/json',
  'Authorization':'string',
  'x-api-key':'string',
  'via-client-sessionid':'string'
};

fetch('https://orgId.via.aspect-cloud.net/via/v2/organizations/{orgId}/messaging/users/{userId}/notification',
{
  method: 'POST',
  body: JSON.stringify(inputBody),
  headers: headers
})
.then(function(res) {
    return res.json();
}).then(function(body) {
    console.log(body);
});

POST https://orgId.via.aspect-cloud.net/via/v2/organizations/{orgId}/messaging/users/{userId}/notification HTTP/1.1
Host: orgid.via.aspect-cloud.net
Content-Type: application/json
Accept: application/json
Authorization: string
x-api-key: string
via-client-sessionid: string

POST /via/v2/organizations/{orgId}/messaging/users/{userId}/notification

To allow for slight message delays in transit, the next composing notification should be sent before the expiresAfterSeconds timeframe. For example, if the expiresAfterSeconds field is set to ten seconds, it is recommended to send the composing state at least once every nine seconds while the user is actively typing. The receiving entity will reset its typing indicator expiration after each composing notification. After the typing indicator expiration (ten seconds in this example) of not receiving the composing notification, the receiving party's UI will hide the typing indicator.

Body parameter

{
  "interactionId": "4321",
  "entityName": "contactCenterAgent",
  "entityType": "Agent",
  "state": "composing",
  "expiresAfterSeconds": 10
}

Parameters

Name In Type Required Description
orgId path string true Name of a customer organization
Authorization header string true Authentication token with the value: 'Bearer {accessToken}', where {accessToken} was returned from a call to the authorization endpoint.
x-api-key header string true Alvaria-provided value used to track API endpoint usage
via-client-sessionid header string true Identifier representing a long-lived HTTP interchange between Alvaria™ Cloud and an entity when the entity is a contact, external client application, or authenticated user. This interchange is called the streaming session. Streaming sessions are used for operations such as exchanging text messages and retrieving events related to user activity.
userId path string true Alvaria-generated unique identifier for a user instance that can be retrieved prior to use from the provisioning rest API. The url is /via/v2/organizations/{orgId}/provisioning/users.
body body NotificationParmsSchema true Client change of state notification, e.g. composing.

Example responses

400 Response

{
  "code": 404,
  "message": "not found",
  "errors": [
    {
      "scope": "scope",
      "reason": "reason",
      "message": "message"
    }
  ]
}

Responses

Status Meaning Description Schema
202 Accepted Successful response None
400 Bad Request Bad Request ErrorResponse
401 Unauthorized Unauthorized None
404 Not Found Not Found ErrorResponse
405 Method Not Allowed Method Not Allowed ErrorResponse
410 Gone Gone ErrorResponse
422 Unprocessable Entity Cannot Process Entity ErrorResponse
429 Too Many Requests Too Many Requests ErrorResponse
500 Internal Server Error Internal server error ErrorResponse
503 Service Unavailable Service Unavailable ErrorResponse

User Push Url

Code samples

# You can also use wget
curl -X POST https://orgId.via.aspect-cloud.net/via/v2/organizations/{orgId}/messaging/users/{userId}/sendUrl \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Authorization: string' \
  -H 'x-api-key: string' \
  -H 'via-client-sessionid: string'

const fetch = require('node-fetch');
const inputBody = {
  "interactionId": "4321",
  "entityName": "contactCenterAgent",
  "entityType": "Agent",
  "url": "https://www.alvaria.com"
};
const headers = {
  'Content-Type':'application/json',
  'Accept':'application/json',
  'Authorization':'string',
  'x-api-key':'string',
  'via-client-sessionid':'string'
};

fetch('https://orgId.via.aspect-cloud.net/via/v2/organizations/{orgId}/messaging/users/{userId}/sendUrl',
{
  method: 'POST',
  body: JSON.stringify(inputBody),
  headers: headers
})
.then(function(res) {
    return res.json();
}).then(function(body) {
    console.log(body);
});

POST https://orgId.via.aspect-cloud.net/via/v2/organizations/{orgId}/messaging/users/{userId}/sendUrl HTTP/1.1
Host: orgid.via.aspect-cloud.net
Content-Type: application/json
Accept: application/json
Authorization: string
x-api-key: string
via-client-sessionid: string

POST /via/v2/organizations/{orgId}/messaging/users/{userId}/sendUrl

This sends a request to the Messaging subsystem containing a URL for an interaction.

Body parameter

{
  "interactionId": "4321",
  "entityName": "contactCenterAgent",
  "entityType": "Agent",
  "url": "https://www.alvaria.com"
}

Parameters

Name In Type Required Description
orgId path string true Name of a customer organization
Authorization header string true Authentication token with the value: 'Bearer {accessToken}', where {accessToken} was returned from a call to the authorization endpoint.
x-api-key header string true Alvaria-provided value used to track API endpoint usage
via-client-sessionid header string true Identifier representing a long-lived HTTP interchange between Alvaria™ Cloud and an entity when the entity is a contact, external client application, or authenticated user. This interchange is called the streaming session. Streaming sessions are used for operations such as exchanging text messages and retrieving events related to user activity.
userId path string true Alvaria-generated unique identifier for a user instance that can be retrieved prior to use from the provisioning rest API. The url is /via/v2/organizations/{orgId}/provisioning/users.
body body SendUrlParmsSchema true send URL information

Example responses

400 Response

{
  "code": 404,
  "message": "not found",
  "errors": [
    {
      "scope": "scope",
      "reason": "reason",
      "message": "message"
    }
  ]
}

Responses

Status Meaning Description Schema
202 Accepted Successful response None
400 Bad Request Bad Request ErrorResponse
401 Unauthorized Unauthorized None
404 Not Found Not Found ErrorResponse
405 Method Not Allowed Method Not Allowed ErrorResponse
410 Gone Gone ErrorResponse
422 Unprocessable Entity Cannot Process Entity ErrorResponse
429 Too Many Requests Too Many Requests ErrorResponse
500 Internal Server Error Internal server error ErrorResponse
503 Service Unavailable Service Unavailable ErrorResponse

Schemas

SendTextParmsSchema

{
  "interactionId": "4321",
  "entityName": "contactCenterAgent",
  "entityType": "Agent",
  "text": "Hi this is an example of a text string."
}

Properties

Name Type Required Restrictions Description
interactionId string true none Alvaria-generated unique identifier for the interaction for which you want to send text.
entityName string true none This contains the name of the entity for which you want to send text.
entityType string true none This contains the type of entity for which you want to send text.
text string true none This is the text string that you want to send.

Enumerated Values

Property Value
entityType Agent
entityType Monitor
entityType System

NotificationParmsSchema

{
  "interactionId": "4321",
  "entityName": "contactCenterAgent",
  "entityType": "Agent",
  "state": "composing",
  "expiresAfterSeconds": 10
}

Properties

Name Type Required Restrictions Description
interactionId string true none Alvaria-generated unique identifier for the interaction for which you want to send text.
entityName string true none This contains the name of the entity for which you want to send text.
entityType string true none This contains the type of entity for which you want to send text.
state string true none Client change of state notification, e.g. composing.
expiresAfterSeconds integer false none Number of seconds the notification should be considered active. Maximum value is 30 seconds.

Enumerated Values

Property Value
entityType Agent
entityType Monitor
entityType System
state composing

SendUrlParmsSchema

{
  "interactionId": "4321",
  "entityName": "contactCenterAgent",
  "entityType": "Agent",
  "url": "https://www.alvaria.com"
}

Properties

Name Type Required Restrictions Description
interactionId string true none Alvaria-generated unique identifier for the interaction for which you want to send a URL.
entityName string true none This contains the name of the entity for which you want to send a URL.
entityType string true none This contains the type of the entity for which you want to send a URL.
url string true none This contains a URL.

Enumerated Values

Property Value
entityType Agent
entityType Monitor
entityType System

ErrorResponse

{
  "code": 404,
  "message": "not found",
  "errors": [
    {
      "scope": "scope",
      "reason": "reason",
      "message": "message"
    }
  ]
}

Properties

Name Type Required Restrictions Description
code integer false none HTTP error status
message string false none none
errors [Error] false none none

Error

{
  "scope": "scope",
  "reason": "reason",
  "message": "message"
}

Properties

Name Type Required Restrictions Description
scope string false none none
reason string false none none
message string false none none