India Template Management with RCS API

RCS Platform mandates that Indian Business must use a pre-approved message template to send one-off message or a message to initiate conversation with the user. There is no further restriction in messaging. Any message can be send to a user within 24-hours of receiving a response from him.

Overview

Templates are pre-defined messages that have been approved by RBM for use in business messaging. They can be of different types and are used to send messages directly to users, in batches as part of a campaign, or as part of an interactive business application workflow.

Templates need to be approved by RBM before they can be used. This usually happens quickly, within a few minutes of submission or it might take few hours.

Create Template API

To create a Template with different type of content, a request is posted to RCS using API Call. Subsequently the Template gets approved or rejected and you get notified over Webhook accordingly.

Note that a template needs to have a name which uniquely identifies wihin other templates in your RBM Agent. A Template can be created for the following type of contents:

  • text: For text only message with interactive options.
  • card: For Rich Media contents with interactive options.
  • carousel: For a carousel of Rich Media Cards with interaction options.

Payload: Standard JSON Format

{
"name": "{template name}",
"type": "{template type}",
"text": "{text message, appears for type:text}",
"card": {"object definition for rich card. appears for type:card"},
"carousel": [{"array of rich cards. appears for type:carousel"}],
"suggestions": [{"array of interactive suggestions. For all types"}],
"templateDetails": {
"username": "{username of account}",
"agent": "{agent name}",
"variables": [
"var1", "var2"
],
"category": "{template type}",
"system_ip": "{system ip}",
"payload": { }
}
}

Explaination of Payload: For all common components

Key/ObjectData TypeConstraintsDescription
nameStringRequiredUnique template name. Used to refer in other APIs
typeEnumeratedRequiredType of template. Enumerated values: text, card, carousel
textStringRequiredText content. Requied when type:text is used. For other types, it shouldn't be used
cardObjectRequiredRich Card definition, explained later in this doc. Requied when type:card is used. For other types, it shouldn't be used
carouselArrayRequiredArray of Rich Card Objects, explained later in this doc. Requied when type:carousel is used. For other types, it shouldn't be used
suggestionsArrayOptionalArray of Interactive Options, viz. Suggestions to act/react. Suggestions are explained here.
templateDetailsObjectRequiredAdditional information related to agent, templates. This object is explained below

Explaination: templateDetails Object

Key/ObjectData TypeConstraintsDescription
usernameStringRequiredAccount username
agentStringRequiredAgent name
variablesArrayOptionalName of variables embeded in text contents.
categoryEnumeratedRequiredSame as type. Enumerated values: text, card, carousel
system_ipStringOptionalIP Address
payloadObjectOptional

Success Response JSON: Template Request is accepted and pending for approval.

{
"code": 200,
"message": "Template request has been created",
"data": { "Complete Request Payload" }
}

Response Explanation: Success condition

|Key / Object| Data Type| Description| |------------|-----------|-------------|-------------| |code |Number | 200 for success. | |message|String | Detailed description | |data|Object | Complete JSON Payload used with API Call is included here. |

Read more....

Template with Text Contents

This is to submit request for a new Template with Text Content.

  • API Route: https://api.enablex.io/rcs/v1/templates
  • Request: POST
  • Authorization: Bearer Token / Basic
  • JSON Payload:
{
"name": "{template name}",
"type": "text",
"text": "{text message}",
"suggestions": [{"array of interactive suggestions. For all types"}],
"templateDetails": {
"username": "{username of account}",
"agent": "{agent name}",
"variables": [
"var1", "var2"
],
"category": "{template type}",
"system_ip": "{system ip}",
"payload": { }
}
}

Explaination of Payload: text type templates sepcific key/objects only

Key/ObjectData TypeConstraintsDescription
typeEnumeratedRequiredUse Enumerated value: text
textStringRequiredText content. Requied when type:text is used. For other types, it shouldn't be used

Explaination: templateDetails Object related to text type templates

Key/ObjectData TypeConstraintsDescription
variablesArrayOptionalName of variables embeded in text contents. Must be used if Text Content has embeded Variables with as [variable] (within SQUARE Bracket)

Read more....

How to use placeholder?

The text key is used to carry text message upto 2500 character long. This text message can have one or many embeded variables which will be replaced while sending a message using actual data.

The embedded variables must follow general guidelines of variable naming convention.

  • A variable name must start with a letter.
  • A variable name cannot start with a digit.
  • A variable name can only contain alpha-numeric characters and underscores (a-z, A-Z, 0-9, and _ ).
  • Variable names are case-sensitive (age, Age and AGE are three different variables).
  • There is no limit on the length of the variable name. Shorter and explanatory names are preferred.
  • A variable name cannot contain spaces and special characters.

Variables placeholders are used within SQUARE Bracket within text contents in text. For example, Hi [name], how about meeting at [location]

Here [name] and [location] are embedded variables.

Template with Rich Card Contents

This is to submit request for a new Template with Rich Media Contents, i.e. Template with Image, Video and Document.

  • API Route: https://api.enablex.io/rcs/v1/templates
  • Request: POST
  • Authorization: Bearer Token / Basic
  • JSON Payload:
{
"name": "{template name}",
"type": "card",
"card": {
"title": "{Plain Text}",
"description": "{Plain Text}",
"url": "{https url of media file}",
"id": "{uploaded file-id}",
"thumbnail_url": "{https url of media file}",
"thumbnail_id": "{uploaded file-id}",
"suggestions": [
{ suggestion }
]
},
"templateDetails": {
"username": "{username of account}",
"agent": "{agent name}",
"category": "{template type}",
"system_ip": "{system ip}",
"payload": { }
}
}

Explaination of Payload: card type templates sepcific key/objects only

Key/ObjectData TypeConstraintsDescription
typeEnumeratedRequiredUse Enumerated value: card
cardObjectRequiredObject definition of Rich Media.

Explaination: card Object related explaination

Key/ObjectData TypeConstraintsDescription
titleStringRequiredTitle or name of the Card or Media
descriptionStringOptionalDescriptive text to follow in the Card
urlStringOptionalPublicly accessible HTTPS hosted URL for the Media File. Can't be used with id
idStringOptionalPre-Uploaded File-ID. Its alternate way to add media to card. Can't be used with url
thumbnail_urlStringOptionalPublicly accessible HTTPS hosted URL for a thubmnail image to be used in against the original larger Media File. Can't be used with thumbnail_id
thumbnail_idStringOptionalPre-Uploaded File-ID. Its alternate way to add thumbnail image to card. Can't be used with thumbnail_url
suggestionsArrayOptionalArray of suggestions. Each card may have one or more suggested actions that the user can interact with.

Read more....

This is to submit request for a new Template with Rich Card Carousel Contents, i.e. Template with a slideshow of Rich Cards with Image, Video and Document.

  • API Route: https://api.enablex.io/rcs/v1/templates
  • Request: POST
  • Authorization: Bearer Token / Basic
  • JSON Payload:
{
"name": "{template name}",
"type": "carousel",
"carousel": [
{
"title": "{Plain Text}",
"description": "{Plain Text}",
"url": "{https url of media file}",
"id": "{uploaded file-id}",
"thumbnail_url": "{https url of media file}",
"thumbnail_id": "{uploaded file-id}",
"suggestions": [
{ suggestion }
]
}
],
"templateDetails": {
"username": "{username of account}",
"agent": "{agent name}",
"category": "{template type}",
"system_ip": "{system ip}",
"payload": { }
}
}

Explaination of Payload: carousel type templates sepcific key/objects only

Key/ObjectData TypeConstraintsDescription
typeEnumeratedRequiredUse Enumerated value: card
carouselArrayRequiredArray of Rich Card Objects. Each card constitutes a slide in a carousel in the given order

Explaination: card Object related explaination arleady given in the previous section.

Read more....

Get list of Templates

This request retrieves a list of templates using the specified API routes, which support filtering options through query string parameters.

  • API Route: https://api.enablex.io/rcs/v1/templates
  • Request: GET
  • Authorization: Bearer Token / Basic
  • Query String Parameters: Used as filter. API Returns full list if called without filter.
ParameterData TypeDescription
nameStringTemplate name. Returns single Template
typeStringTemplate Type. Enumerated values: text, card, carousel
statusStringTemplate Status. Enumerated values: pending, approved, rejected
page_noNumberPage No. Default: 1. Requested Page Number for paginated response.
page_lengthNumberPage Length. Default: 10. Maximum number of Templates to be included in each response.

Request Example: To get all templates with approved status, using a Query String parameter.

GET https://api.enablex.io/rcs/v1/templates?status=approved
Authorization: Bearer Token / Basic
Content-Type: application/json

Response Example: Returns in Array of Objects (Each object is a Template) even if it finds a single template to return.

{ "code": 200,
"message": "Success",
“page_no”: {page number},
“page_length": {page length},
“total”: {total templates},
“data”: [
{ template objects }
]
}
ParameterData TypeDescription
codeNUmber200 for success
page_noNumberResponse with Templates for Page Number
page_lengthNumberPage Number calculated with this Page-Length
totalNumberTotal Number of templates avaialble for the filter used.
dataArrayArray of templates. Each object in the array is a Template definition

Update Template

This is to submit request for update different aspect of a template. The API needs

  • API Route: https://api.enablex.io/rcs/v1/templates/:template_name
  • Request: PATH
  • Authorization: Bearer Token / Basic
  • *URL Embedded Variable: template_name
  • JSON Payload: Use the same JSON definition as explained above to create different type templates. Note that the Payload must be complete to redefine your Template. This process will update the definition of original template name.

Success Response JSON: Template update request has been accepted.

{
"code": 200,
"message": "Template updated",
"data": { "Complete Request Payload" }
}

Response Explanation: Success condition

|Key / Object| Data Type| Description| |------------|-----------|-------------|-------------| |code |Number | 200 for success. | |message|String | Detailed description | |data|Object | Complete JSON Payload used with API Call is included here. |

Delete Template

This request deletes a a given Template name. The API call deletes all templates with the same name across all languages.

  • API Route: https://api.enablex.io/rcs/v1/templates/:template_name
  • Request: DELETE
  • Authorization: Bearer Token / Basic
  • URL Embedded Template Name
DELETE https://api.enablex.io/rcs/v1/templates/my_template_name
Authorization: Bearer Token / Basic
Content-Type: application/json
{
"code": 200,
"message": "Template is deleted"
}