Get started
API Endpoint https://betterchat.in/api/
You can use the this API to send text messages, media/documents, and template messages to your customers.
To use this API, you need an API key. You can find your API key in WhatsApp number page
Conversations are message threads between you and your customers. Conversations can last up to 24-hours and must be initiated by you (business-initiated) or your customers (user-initiated). Customers can initiate a conversation by sending you any type of message, but you can only initiate a conversation with a template message. Once the conversation has begun, you can then send any type of message to the customer.
Send Template
# Here is a curl example
curl \
-X POST https://betterchat.in/api/template/{your_api_key} \
-F 'to_num=recipient number' \
-F 'to_name=recipient name' \
-F 'template=0' \
-F 'media_url=' \
-F 'varibale[]=variable value' \
-F 'button_url[]=' \
To send template message you need to make a POST call to the following url :
https://betterchat.in/api/template/{your_api_key}
Result example :
{
"success" : true,
"id" : "ea3434....",
"message" : "message..",
"timestamp" : "1504902988"
}
QUERY PARAMETERS
Field | Type | Description |
---|---|---|
to_num | Integer | Recipient Phone Number with country code |
to_name | String | (optional) Recipient Name |
template | String | Template Name |
media_url | String | (optional) header media url if selected in templete. must be a valid url and publicly accessible. |
variable | Object |
(optional) body variable value in array object: Like: variable[] = "first value" variable[] = "Second value" .... |
button_url | Object |
(optional) website button dynamic url sub path if selected in templete. Like: button_url[] = "/order/view/111.." button_url[] = "/order/view/112.." |
Send Message
# Here is a curl example
curl \
-X POST https://betterchat.in/api/message/{your_api_key} \
-F 'to_num=recipient number' \
-F 'to_name=recipient name' \
-F 'message= any message...'
To send message you need to make a POST call to the following url :
https://betterchat.in/api/message/{your_api_key}
Result example : { "success" : true, "id" : "ea3434....", "message" : "message..", "timestamp" : "1504902988" }
# Here is a curl example with interactive message curl \ -X POST https://betterchat.in/api/message/{your_api_key} \ -F 'to_num=recipient number' \ -F 'to_name=recipient name' \ -F 'message= any message...'\ -F 'interactive[type]= button or list '\ -F 'interactive[name]= menu button title or name if type is list'\ -F 'interactive[data][0][id] = unique id '\ -F 'interactive[data][0][title] = button or list menu name'\ -F 'interactive[data][0][description] = any description if type is list
Result example :
{
"success" : true,
"id" : "ea3434....",
"message" : "message..",
"timestamp" : "1504902988"
}
QUERY PARAMETERS
Field | Type | Description |
---|---|---|
to_num | Integer | Recipient Phone Number with country code |
to_name | String | (optional) Recipient Name |
message | String | Message content |
interactive | Object |
(optional) send list or button in message: Send upto 3 buttons or 9 list option |
You can only initiate a conversation with a template message. Once the conversation has begun, you can then send any type of message to the customer. Customers can also initiate a conversation by sending you any type of message
Interactive example
For buttons:
interactive[type] = "button"
interactive[data][0]['id'] = "1"
interactive[data][0]['title'] = "Option 1"
interactive[data][1]['id'] = "2"
interactive[data][1]['title'] = "Option 2"
For list:
interactive[type] = "list"
interactive[name] = "menu button name (default menu)"
interactive[data][0]['id'] = "1"
interactive[data][0]['title'] = "Option 1"
interactive[data][0]['description'] = "description 1"
interactive[data][1]['id'] = "2"
interactive[data][1]['title'] = "Option 2"
interactive[data][1]['description'] = "description 2"
Send Attachment
# Here is a curl example
curl \
-X POST https://betterchat.in/api/attachment/{your_api_key} \
-F 'to_num=recipient number' \
-F 'to_name=recipient name' \
-F 'link=media link' \
-F 'caption= any caption...'
To send attachment you need to make a POST call to the following url :
https://betterchat.in/api/attachment/{your_api_key}
Result example :
{
"success" : true,
"id" : "ea3434....",
"message" : "message..",
"timestamp" : "1504902988"
}
QUERY PARAMETERS
Field | Type | Description |
---|---|---|
to_num | Integer | Recipient Phone Number with country code |
to_name | String | (optional) Recipient Name |
link | String | Media link |
caption | String | (optional) Any caption |
Errors
The Betterflow API uses the following error codes:
Error Code | Meaning |
---|---|
101 | Some parameters are missing. This error appears when you don't pass every mandatory parameters. |
102 |
Unknown or unvalid api_key . This error appears if you use an unknow API key or if your API key expired.
|
103 | to_num parameter is missing. |
104 |
Unvalid parameter value . This error appears if you pass invalid value like wrong template name.
|