01. Understanding RCS Payload Structure - Simple Text Example

While sending simple payloads through SCG via CURL is really straight forward, voice and rich content payloads and behaviors imply a higher level of complexity. RCS payload is a succession of  JSON objects that can easily get unmanageable if we don't code them in a proper hierarchy that helps developers to understand and easily manipulate/modify them. 

This exercise's intent is to provide a human perspective of RCS payload structures helping users and developers to better understand the formal structures defined in SCG-Supplementary-RCS-API-Reference 

In order to do that, we will use one of the most simple structures: text delivered over an RCS sender ID.  

The structure of the REST API call contains the  same elements of a regular message

POST
'https://api.syniverse.com/scg-external-api/api/v1/messaging/message_requests’
--header 'Authorization: Bearer <your application TOKEN>
--header 'Content-Type: application/json'

While the application/json content being sent includes an additional field "content_type" and a very particular form of "body" 

{
"from":"<your sender id>",
"to":["<Your RCS Test Phone>"],
"body":"{\"contentMessage\": {\"text\":\"WELCOME TO YOUR RCS EXPERIENCE\"}",
"content_type":"application/vnd.scg.grcs.raw-message"
}

As you may already notice there is a new element "content_type":"application/vnd.scg.grcs.raw-message" and  "body" contains a serialization of a JSON called ContentMessage: that identifies the content of a RCS message sent from the Business to an end-user.

Imagine how this ContentMessage serialized JSON would look like for a rich card or a carousel with multiple cards inside containing images, titles, descriptions and suggestions, the need for a better coding approach becomes evident.

To start the process  in a step/by/step approach we selected the text scenario, that requires a very simple structure. {"text":"WELCOME TO YOUR RCS EXPERIENCE"}

mceclip1.png

The String resulting from the serialization of such payload t would be:

"{\"contentMessage\": {\"text\":\"WELCOME TO YOUR RCS EXPERIENCE\"}"

 

SYNIVERSE SCG JAVA-SCRIPT CODING RCS PAYLOAD

The focus of this sessions is to manipulate and code towards RCS Payloads using Java Script (commonly used across multiple BOT platforms / Applications as well as POSTMAN Pre RequestScripts.

//Special consideration to the payload of the "body" RCS Message element
var message = {"contentMessage": {"text":"WELCOME TO YOUR RCS EXPERIENCE"}};

//body element serialization
var jSONMessage = JSON.stringify(message);

var body={
"from":"<your sender id>",
"to":["+1xxxxxx"],
"content_type":"application/vnd.scg.grcs.raw-message",
"body":jSONMessage
};

 

After a 200 OK response the mobile experience should be:

mceclip4.png

Was this article helpful?
0 out of 0 found this helpful

0 Comments

Article is closed for comments.