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/Object | Data Type | Constraints | Description |
---|---|---|---|
name | String | Required | Unique template name. Used to refer in other APIs |
type | Enumerated | Required | Type of template. Enumerated values: text , card , carousel |
text | String | Required | Text content. Requied when type:text is used. For other types, it shouldn't be used |
card | Object | Required | Rich Card definition, explained later in this doc. Requied when type:card is used. For other types, it shouldn't be used |
carousel | Array | Required | Array of Rich Card Objects, explained later in this doc. Requied when type:carousel is used. For other types, it shouldn't be used |
suggestions | Array | Optional | Array of Interactive Options, viz. Suggestions to act/react. Suggestions are explained here. |
templateDetails | Object | Required | Additional information related to agent, templates. This object is explained below |
Explaination: templateDetails
Object
Key/Object | Data Type | Constraints | Description |
---|---|---|---|
username | String | Required | Account username |
agent | String | Required | Agent name |
variables | Array | Optional | Name of variables embeded in text contents. |
category | Enumerated | Required | Same as type . Enumerated values: text , card , carousel |
system_ip | String | Optional | IP Address |
payload | Object | Optional |
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/Object | Data Type | Constraints | Description |
---|---|---|---|
type | Enumerated | Required | Use Enumerated value: text |
text | String | Required | Text content. Requied when type:text is used. For other types, it shouldn't be used |
Explaination: templateDetails
Object related to text
type templates
Key/Object | Data Type | Constraints | Description |
---|---|---|---|
variables | Array | Optional | Name 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/Object | Data Type | Constraints | Description |
---|---|---|---|
type | Enumerated | Required | Use Enumerated value: card |
card | Object | Required | Object definition of Rich Media. |
Explaination: card
Object related explaination
Key/Object | Data Type | Constraints | Description |
---|---|---|---|
title | String | Required | Title or name of the Card or Media |
description | String | Optional | Descriptive text to follow in the Card |
url | String | Optional | Publicly accessible HTTPS hosted URL for the Media File. Can't be used with id |
id | String | Optional | Pre-Uploaded File-ID. Its alternate way to add media to card. Can't be used with url |
thumbnail_url | String | Optional | Publicly 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_id | String | Optional | Pre-Uploaded File-ID. Its alternate way to add thumbnail image to card. Can't be used with thumbnail_url |
suggestions | Array | Optional | Array of suggestions. Each card may have one or more suggested actions that the user can interact with. |
Read more....
Template with Rich Card Carousel Contents
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/Object | Data Type | Constraints | Description |
---|---|---|---|
type | Enumerated | Required | Use Enumerated value: card |
carousel | Array | Required | Array 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.
Parameter | Data Type | Description |
---|---|---|
name | String | Template name. Returns single Template |
type | String | Template Type. Enumerated values: text , card , carousel |
status | String | Template Status. Enumerated values: pending , approved , rejected |
page_no | Number | Page No. Default: 1. Requested Page Number for paginated response. |
page_length | Number | Page 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=approvedAuthorization: Bearer Token / BasicContent-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 }]}
Parameter | Data Type | Description |
---|---|---|
code | NUmber | 200 for success |
page_no | Number | Response with Templates for Page Number |
page_length | Number | Page Number calculated with this Page-Length |
total | Number | Total Number of templates avaialble for the filter used. |
data | Array | Array 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_nameAuthorization: Bearer Token / BasicContent-Type: application/json
{"code": 200,"message": "Template is deleted"}