Webhooks
Webhooks allow you to receive real-time updates when a specific event occurs, i.e. message is received from a contact. These events are HTTP POST requests being sent to an endpoint of your server. Similarly to Amio Messaging API, body of such request is in JSON format. All events which happen in a specific channel are delivered to a single webhook url (i.e. https://your-server.com/webhook) which you can set in administration.
When you receive a webhook event, you should always return HTTP response in 2xx class, i.e. 200 OK in shortest time possible (we close the connections which takes longer then 60 seconds). If the webhook request fails or exceeds the maximum time, Amio will try to re-deliver the webhook again later (see Webhook Re-Delivery).
📘 Set Webhook URL
- Login to app.amio.io.
- Pick a channel from channels.
- Select tab Webhook and set Webhook Url.
Webhook Content
Section titled “Webhook Content”All webhooks have following body structure:
{ "event": "{{EVENT_NAME}}", "timestamp" : "{{ISO_8601_TIMESTAMP}}", "data" : { "{{event type specific data}}" }}| Parameter | Type | Description |
|---|---|---|
| event | string | Event type name. See Events for complete list of events emitted by Amio. |
| timestamp | string | Iso 8601 Timestamp - time when we sent you the webhook. |
| data | object | Event type specific data object. |
Webhook Re-Delivery
Section titled “Webhook Re-Delivery”If your webhook fails with response code 4xx or 5xx, Amio will try to re-deliver the webhook again. There are several re-delivery events after 1, 5, 20, 60, 180 and 480 minutes. If all retries fail, the webhook call is discarded.
Events
Section titled “Events”Different events are fired by Amio. There are common events to all channel types, however, there are also events specific to each channel, see Channel Events chapter for a complete list of channel-specific events.
Message Received
Section titled “Message Received”This event is fired when a contact sends a message to your channel. Request body contains channel type on which the event was handled as well as id of the contact. Different type of messages can be received based on channel.type.
{ "event": "message_received", "timestamp": "2016-10-06T13:42:48Z", "data": { "id": "{{MESSAGE_ID}}", "channel": { "id": "{{CHANNEL_ID}}", "type": "{{CHANNEL_TYPE}}", "name": "{{CHANNEL_NAME}}" }, "contact": { "id": "{{CONTACT_ID}}" }, "content": { "payload": "What's the weather today?", "type": "text" }, "nlp": { "intents": [ { "confidence": 0.99847021852548, "id": "weather" } ], "native_data": {...} }, }}| Parameter | Type | Description |
|---|---|---|
| data | object | Object representing message received. Different type of messages can be received (text, image, etc.). The structure matches Send Message response body except for the nlp key (see below). This key will be present only for received text messages on channels with NLP connected. |
Natural Language Processing (NLP)
Section titled “Natural Language Processing (NLP)”If there’s an NLP connected to your channel, then your Message Received webhook will contain an nlp key with the result provided by the NLP service. Since different NLP services provide different extra capabilities and parameters beyond simple intent/entity extraction, we also include full JSON response from the service.
| Parameter | Type | Description |
|---|---|---|
| nlp.intents | array of objects | List of intents ordered by confidence score. |
| nlp.intents[].id | string | Name (or other unique identifier) of the intent. |
| nlp.intents[].confidence | number | Confidence score of the intent. |
| nlp.native_data | object | Full unmodified JSON response as returned by the NLP service. For more information, please refer to the documentation of the service: • Wit.ai • Watson |
Messages Delivered
Section titled “Messages Delivered”This event notifies you of messages that were delivered to your contact.
{ "event": "messages_delivered", "timestamp": "2016-10-06T13:42:48Z", "data": { "channel": { "id": "6456078759331238786", "type": "{{CHANNEL_TYPE}}" }, "contact": { "id": "6456078781510718339" }, "messages": [ { "id": "6456078996108088196" }, { "id": "6456079002382766981" } ], "delivered_timestamp": "2016-10-06T13:40:01Z" }}| Parameter | Type | Description |
|---|---|---|
| data.channel | object | Channel where the data.contact resides in. |
| data.contact | object | Contact to whom the messages were delivered. |
| data.messages | array of messages | Array of messages that were delivered. Every message will contain message.id. Depending on platform used, the message can contain other fields. |
| data.delivered_timestamp | string | Iso 8601 Timestamp. The time of message delivery to the user’s device. This value may vary from webhook timestamp attribute if provided by the platform. If the platform doesn’t provide this time, Amio uses time when the webhook came to our servers. |
Message Failed
Section titled “Message Failed”This event occurs only for some platforms and notifies you about a message that could not be. This may happen when given phone number is wrong or message expires, etc.
{ "event": "message_failed", "timestamp" : "2017-12-29T17:26:17.331Z", "data" : { "channel": { "id": "6456078759331238786", "type": "{{CHANNEL_TYPE}}" }, "contact": { "id": "6456078781510718339", "phone_number": "15558576309", }, "message": { "id": "6456078996108088196" }, "error": { "code": 1, "message": "Error while processing the request." } }}| Parameter | Type | Description |
|---|---|---|
| data.channel | object | Channel where the data.contact resides in. |
| data.contact | object | Contact to whom the message was sent but not delivered. |
| data.message | object | Messages which was sent, will contain only message.id. |
| data.error.code | number | Error code, see errors below. |
| data.error.message | string | Detail message of an error, see errors below. |
Errors
Section titled “Errors”| Error Code | Reason |
|---|---|
| 1 | Error while processing the request. |
| 2 | Sending messages to this user is blocked. |
| 3 | Cannot find user for given phone number. |
| 4 | Message failed to be delivered within 24 hours. |
Messages Read
Section titled “Messages Read”This event notifies you of messages that a contact has read.
{ "event": "messages_read", "timestamp": "2016-10-06T13:42:48Z", "data": { "channel": { "id": "6456078759331238786", "type": "{{CHANNEL_TYPE}}" }, "contact": { "id": "6456078781510718339" }, "last_read_timestamp": "2016-10-06T13:40:13Z" }}| Parameter | Type | Description |
|---|---|---|
| data.channel | object | Channel where the data.contact resides in. |
| data.contact | object | Contact that has read messages delivered. |
| last_read_timestamp | string | Iso 8601 Timestamp All messages before this timestamp were read. |
Message Echo
Section titled “Message Echo”Message echo event is invoked whenever a message is sent to a contact. This callback allows you to track all messages being sent no matter if they’re sent by your channel or by someone else. For example, messages sent to Facebook users directly from Facebook Page administration or messages sent by some other Amio channel can be easily recorded.
{ "event": "message_echo", "timestamp": "2016-10-06T13:42:48Z", "data": { "id": "{{MESSAGE_ID}}", "channel": { "id": "{{CHANNEL_ID}}", "type": "{{CHANNEL_TYPE}}", "name": "{{CHANNEL_NAME}}" }, "contact": { "id": "{{CONTACT_ID}}" }, "content": { "type": "text", "payload": "We know, we try really hard to bring always something more to our beloved customers!" }, "metadata": { "any": "arbitrary data" } }}| Parameter | Type | Description |
|---|---|---|
| data | object | Object representing message which is echoed. Different type of messages can be received (text, image, etc.). The structure matches Send Message response body. |
Channel Events
Section titled “Channel Events”- Facebook Messenger - Webhooks
- Viber Bot - Webhooks
- Viber Business Messages - Webhooks
- Mobile - Webhooks
Security
Section titled “Security”Once your server is configured to receive webhook events, it’ll listen for any payload sent to the endpoint you configured. For security reasons, you probably want to limit requests to those coming from Amio. There are few ways to go about this, for example, you could opt to whitelist requests from Amio’s IP address but a far easier method is to set up a secret token and validate the information using secret token.
You can find your secret token in Amio settings.
Amio uses this secret token to create a hash signature with each payload. The HTTP request will contain an X-Hub-Signature header which contains the SHA1 signature of the request payload, using the secret token as the key and prefixed with sha1= string. Your callback endpoint can verify this signature to validate the integrity and origin of the payload.
Here is the code how to calculate X-Hub-Signature:
const crypto = require('crypto')
function calculateXHubSignature(secret, body /* as string */) { const hmac = crypto.createHmac('sha1', secret) hmac.update(body) return `sha1=${hmac.digest('hex')}`}Java
import org.apache.commons.codec.binary.Hex
import javax.crypto.Macimport javax.crypto.spec.SecretKeySpecimport java.nio.charset.Charset
class WebhookSecurityService {
public static String calculateXHubSignature(String secret, String body) { Mac hmac = Mac.getInstance("HmacSHA1"); hmac.init(new SecretKeySpec(secret.getBytes(Charset.forName("UTF-8")), "HmacSHA1")); return "sha1=" + Hex.encodeHexString(hmac.doFinal(body.getBytes(Charset.forName("UTF-8")))); }}// credits goes to Michal Pustějovský <mpustejovsky@dpd.cz>
using System;using System.Text;using System.Security.Cryptography;
namespace Webhook{ public class WebhookSecurityService { public string WebhookSecurity(string secret, string body) { var hmac = new HMACSHA1(Encoding.UTF8.GetBytes(secret)); var byteHash = hmac.ComputeHash(Encoding.UTF8.GetBytes(body)); return "sha1=" + BitConverter.ToString(byteHash).Replace("-", "").ToLower(); } }}Verify your algorithm with following values:
secret = 'WebhookSecret'body = '{"event":"messages_delivered","timestamp":"2018-03-01T11:54:14.886Z","data":{"channel":{"id":"viber_service_messages_test","type":"viber"},"contact":{"phone_number":"+420606123456"},"messages":[{"id":"151990525359991"}]}}'The calculated X-Hub-Signature should equal to sha1=cb041d03489e961730cb6c7a6d1edf58ae88ef13.
Channel-specific webhook events
Section titled “Channel-specific webhook events”Select a channel to see its specifics.
Amio Chat: Overview
Section titled “Amio Chat: Overview”See general webhook documentation for instructions on how to set up webhooks for your app and further details. This section will walk you through all common webhooks as well as webhooks specific to Amio Chat platform.
Amio Chat: Message Received
Section titled “Amio Chat: Message Received”This event is fired whenever a contact sends a message to your channel.
{ "event": "message_received", "timestamp": "2019-03-27T18:42:48Z", "data": { "id": "6456078996108099701", "channel": { "id": "6456078759331248741", "type": "amio_chat" }, "contact": { "id": "6456078781510715474" }, "content": { "type": "text", "payload": "That's really nice that I can write you here. You guys rock!", "quick_reply": { "payload": "DEVELOPER_DEFINED_PAYLOAD" } }, "nlp": {...} }}| Parameter | Type | Description |
|---|---|---|
| data | object | Object representing message received. Different type of messages can be received (text, image, etc.). The structure matches Send Message response structure except for the nlp key which is valid only for received messages. |
Amio Chat: Messages Delivered
Section titled “Amio Chat: Messages Delivered”This event occurs when a message has been delivered to contact.
{ "event": "messages_delivered", "timestamp" : "2016-10-06T13:42:48Z", "data" : { "channel": { "id": "6456078759331248741", "type": "amio_chat" }, "contact": { "id": "6456078781510715474" }, "messages": [ { "id": "6456078996108099701" }, { "id": "6456078996108097880" } ], "delivered_timestamp": "2016-10-06T13:40:01Z" }}| Parameter | Type | Description |
|---|---|---|
| data.channel | object | Channel where the data.contact resides in. |
| data.contact | object | Contact to whom the messages were delivered. |
| data.messages | array | Array of messages that were delivered. Every message will contain message.id. |
| data.delivered_timestamp | string | Iso 8601 Timestamp. The time of message delivery to the user’s device. This value may vary from webhook timestamp attribute due to delays. |
Amio Chat: Messages Read
Section titled “Amio Chat: Messages Read”This event occurs when a message has been read by the contact.
{ "event": "messages_read", "timestamp" : "2016-10-06T13:42:48Z", "data" : { "channel": { "id": "6456078759331248741", "type": "amio_chat" }, "contact": { "id": "6456078781510715474" }, "last_read_timestamp": "2016-10-06T13:40:13Z" }}| Parameter | Type | Description |
|---|---|---|
| data.channel | object | Channel where the data.contact resides in. |
| data.contact | object | Contact that has read messages delivered. |
| last_read_timestamp | string | Iso 8601 Timestamp All messages that were delivered before this timestamp were read. (It doesn’t mean “time when the messages were read”.) |
Amio Chat: Message Echo
Section titled “Amio Chat: Message Echo”Message echo event is invoked whenever message is sent to user. This callback allows you to track all messages being sent no matter if they’re sent by you or by someone else.
{ "event": "message_echo", "timestamp": "2016-10-06T13:42:48Z", "data": { "id": "6456078996108099701", "channel": { "id": "6456078759331248741", "type": "amio_chat" }, "contact": { "id": "6456078781510715474" }, "content": { "type": "text", "payload": "We know, we try really hard to bring always something more to our beloved customers!" }, "metadata": { "any": "arbitrary data" } }}| Parameter | Type | Description |
|---|---|---|
| data | object | Object representing message which is echoed. Different type of messages can be received (text, image, etc.). The structure matches Send Message response body. |
Amio Chat: Notification Received
Section titled “Amio Chat: Notification Received”Notification event is invoked by the client and can be used to send any notification events like chat opened, chat closed, etc.
{ "event": "notification", "timestamp": "2019-03-28T12:36:34.873Z", "data": { "channel": { "id": "6456078759331248741", "type": "amio_chat" }, "contact": { "id": "6456078781510715474" }, "type": "custom", "payload": { "any": "arbitrary data" } }}| Parameter | Type | Description |
|---|---|---|
| data | object | Object representing notification received. Only custom notification is supported from client side, see Send Notification for more details. |
Amio Chat: Postback Received
Section titled “Amio Chat: Postback Received”This event occurs when the user presses a Postback Button (which can be a part of a Structured Message). You can react to this event by performing an action or by sending a reply.
{ "event": "postback", "timestamp": "2020-03-01T15:49:02.243Z", "data": { "channel": { "id": "6456078759331238786", "type": "amio_chat" }, "contact": { "id": "6456078781510718339" }, "postback": { "payload": "{{DEVELOPER_DEFINED_PAYLOAD}}" } }}| Parameter | Type | Description |
|---|---|---|
| postback.payload | string | Payload of the Postback Button that has been pressed. |
Email (Daktela): Overview
Section titled “Email (Daktela): Overview”See general webhook documentation for instructions on how to set up webhooks for your app and further details. This section will walk you through all common webhooks as well as webhooks specific to Emails.
Email (Daktela): Message Received
Section titled “Email (Daktela): Message Received”This event is fired whenever a contact sends a message to your channel.
{ "event": "message_received", "timestamp": "2019-03-27T18:42:48Z", "data": { "id": "6456078996108099701", "channel": { "id": "6456078759331248741", "type": "email_daktela" }, "contact": { "id": "6619975808952586225", "email": "john@customer.com" }, "content": { "type": "text", "payload": "My cat got lost!" } }}| Parameter | Type | Description |
|---|---|---|
| data | object | Object representing message received. It copies the structure of emails sent . |
Facebook Messenger: Overview
Section titled “Facebook Messenger: Overview”See general webhook documentation for instructions on how to set up webhooks for your app and further details. This section will walk you through all common webhooks as well as webhooks specific to Facebook Messenger platform.
Facebook Messenger: Message Received
Section titled “Facebook Messenger: Message Received”This event is fired whenever a contact sends a message to your Facebook page.
📘 Amio Persists Message Files
All incoming messages having a file url attachments (i.e. Image Message, Video Message, etc.) are persisted on Amio servers due to expiration reasons.
{ "event": "message_received", "timestamp": "2016-10-06T13:42:48Z", "data": { "id": "6456078996108088196", "channel": { "id": "6456078759331238786", "type": "facebook_messenger" }, "contact": { "id": "6456078781510718339" }, "content": { "type": "text", "payload": "That's really nice that I can write you here. You guys rock!", "quick_reply": { "payload": "DEVELOPER_DEFINED_PAYLOAD" } }, "nlp": {...} }}| Parameter | Type | Description |
|---|---|---|
| data | object | Object representing message received. Different type of messages can be received (text, image, etc.). The structure matches Send Message response structure except for the nlp key which is valid only for received messages. |
Facebook Messenger: Messages Delivered
Section titled “Facebook Messenger: Messages Delivered”This event occurs when a message has been delivered to contact.
{ "event": "messages_delivered", "timestamp" : "2016-10-06T13:42:48Z", "data" : { "channel": { "id": "6456078759331238786", "type": "facebook_messenger" }, "contact": { "id": "6456078781510718339" }, "messages": [ { "id": "6456078996108088196" }, { "id": "6456079002382766981" } ], "delivered_timestamp": "2016-10-06T13:40:01Z" }}| Parameter | Type | Description |
|---|---|---|
| data.channel | object | Channel where the data.contact resides in. |
| data.contact | object | Contact to whom the messages were delivered. |
| data.messages | array | Array of messages that were delivered. Every message will contain message.id. |
| data.delivered_timestamp | string | Iso 8601 Timestamp. The time of message delivery to the user’s device. This value may vary from webhook timestamp attribute due to delays. |
Facebook Messenger: Messages Read
Section titled “Facebook Messenger: Messages Read”This event occurs when a message has been read by the contact.
{ "event": "messages_read", "timestamp" : "2016-10-06T13:42:48Z", "data" : { "channel": { "id": "6456078759331238786", "type": "facebook_messenger" }, "contact": { "id": "6456078781510718339" }, "last_read_timestamp": "2016-10-06T13:40:13Z" }}| Parameter | Type | Description |
|---|---|---|
| data.channel | object | Channel where the data.contact resides in. |
| data.contact | object | Contact that has read messages delivered. |
| last_read_timestamp | string | Iso 8601 Timestamp All messages that were sent before this timestamp were read. (It doesn’t mean “time when the messages were read”.) |
Facebook Messenger: Message Echo
Section titled “Facebook Messenger: Message Echo”Message echo event is invoked whenever message is sent to user. This callback allows you to track all messages being sent no matter if they’re sent by you or by someone else. For example messages sent to Facebook users directly from Facebook Page administration can be easily recorded. The same situation can happen when you reply the user from Amio integration (i.e. you reply from Zendesk).
{ "event": "message_echo", "timestamp": "2016-10-06T13:42:48Z", "data": { "id": "6456078996108088196", "channel": { "id": "6456078759331238786", "type": "facebook_messenger" }, "contact": { "id": "6456078781510718339" }, "content": { "type": "text", "payload": "We know, we try really hard to bring always something more to our beloved customers!" }, "metadata": { "any": "arbitrary data" } }}| Parameter | Type | Description |
|---|---|---|
| data | object | Object representing message which is echoed. Different type of messages can be received (text, image, etc.). The structure matches Send Message response body. |
Facebook Messenger: Postback Received
Section titled “Facebook Messenger: Postback Received”This callback occurs when the user presses Postback Button or Get Started Button. You can use this event to perform certain action or to reply back.
{ "event": "postback", "timestamp": "2017-03-01T15:49:02.243Z", "data": { "channel": { "id": "6456078759331238786", "type": "facebook_messenger" }, "contact": { "id": "6456078781510718339" }, "postback": { "payload": "{{PASS_THROUGH_PARAM}}" } }}| Parameter | Type | Description |
|---|---|---|
| payload | string | Developer-defined data set in Postback Button or Get Started Button. |
Facebook Messenger: Opt-in
Section titled “Facebook Messenger: Opt-in”Opt-in webhook is fired for several actions and is generally meant for binding a user in your application. This webhook is fired when:
- Send to Messenger is clicked.
- Checkbox Plugin is ticked.
- Phone Number Matching procedure is called.
- m.me Link is clicked
Opt-in for Send to Messenger
Section titled “Opt-in for Send to Messenger”When user presses Send to Messenger button, you will receive following webhook.
{ "event": "opt_in", "timestamp": "2016-10-06T13:42:48Z", "data": { "channel": { "id": "6456078759331238786", "type": "facebook_messenger" }, "contact": { "id": "6456078781510718339" }, "opt_in": { "type": "send_to_messenger", "payload": "{{PASS_THROUGH_PARAM}}" } }}| Parameter | Type | Description |
|---|---|---|
| opt_in.type | string | Describes what type of opt-in this is. In case of Send to Messenger, this will always be send_to_messenger. |
| opt_in.payload | string | Data set in Send to Messenger Button as data-ref attribute. |
Opt-in for Checkbox
Section titled “Opt-in for Checkbox”When user ticks Checkbox plugin, you will receive following webhook.
{ "event": "opt_in", "timestamp": "2016-10-06T13:42:48Z", "data": { "channel": { "id": "6456078759331238786", "type": "facebook_messenger" }, "contact": { "id": "6456078781510718339", "user_ref": "{{YOUR_CUSTOM_USER_REF}}" // set on frontend checkbox plugin }, "opt_in": { "type": "checkbox", "payload": "{{PASS_THROUGH_PARAM}}" } }}| Parameter | Type | Description |
|---|---|---|
| contact.user_ref | string | Data that has been set in checkbox plugin user_ref attribute. It is should be uniquely generated string ID (unique for each render). |
| opt_in.type | string | Describes what type of opt-in this is. In case of Checkbox plugin, this will always be checkbox. |
| opt_in.payload | string | Data that has been set in checkbox plugin ref attribute. |
Opt-in for Phone Number Matching
Section titled “Opt-in for Phone Number Matching”This webhook is sent when a user accepts the message request sent to his phone number using Phone Number Entry Point.
{ "event": "opt_in", "timestamp": "2016-10-06T13:42:48Z", "data": { "channel": { "id": "6456078759331238786", "type": "facebook_messenger" }, "contact": { "id": "6456078781510718339", "phone_number": "15558576309" }, "opt_in": { "type": "phone_number" } }}| Parameter | Type | Description |
|---|---|---|
| contact.phone_number | string | Phone number in E.164 format. |
| opt_in.type | string | Describes what type of opt-in this is. In case of Phone Number Matching, this will always be phone_number. |
Mobile (SMS): Overview
Section titled “Mobile (SMS): Overview”See general webhook documentation for instructions on how to set up webhooks for your app and further details.
Mobile (SMS): Message Received
Section titled “Mobile (SMS): Message Received”This event is fired whenever a contact sends a message to your dedicated phone number or replies to you in case of shared number.
{ "event": "message_received", "timestamp": "2016-10-06T13:42:48Z", "data": { "id": "6456078996108088196", "channel": { "id": "6456078759331238786", "type": "mobile" }, "contact": { "id": "6456078781510718339", "phone_number": "15558576309" }, "content": { "type": "text", "payload": "That's really nice that I can write you back. You guys rock!" }, "nlp": {...} }}| Parameter | Type | Description |
|---|---|---|
| data | object | Object representing message received. The structure matches Send Message response structure except for the nlp key which is valid only for received messages. |
Mobile (SMS): Messages Delivered
Section titled “Mobile (SMS): Messages Delivered”This event notifies you of messages that were delivered to your contact.
{ "event": "messages_delivered", "timestamp" : "2017-12-29T17:26:17.331Z", "data" : { "channel": { "id": "6456078759331238786", "type": "mobile" }, "contact": { "id": "6456078781510718339", "phone_number": "15558576309" }, "messages": [ { "id": "6456078996108088196" } ], "delivered_timestamp": "2017-12-29T17:26:16.001Z" }}| Parameter | Type | Description |
|---|---|---|
| data.channel | object | Channel where the data.contact resides in. |
| data.contact | object | Contact to whom the messages were delivered. |
| data.messages | array | Array of messages that were delivered. Every message will contain message.id. |
| data.delivered_timestamp | string | Iso 8601 Timestamp. The time when Amio servers received notification about message delivery. This value may vary from webhook timestamp attribute due to delays. |
Mobile (SMS): Message Failed
Section titled “Mobile (SMS): Message Failed”This event notifies you of a message that could not be sent. This may happen when given phone number is wrong or when message send expires.
{ "event": "message_failed", "timestamp" : "2017-12-29T17:26:17.331Z", "data" : { "channel": { "id": "1527759271281586456078759331238786", "type": "mobile" }, "contact": { "id": "6456078781510718339", "phone_number": "15558576309" }, "message": { "id": "6456078996108088196" }, "error": { "code": 1, "message": "Error while processing the request." } }}| Parameter | Type | Description |
|---|---|---|
| data.channel | object | Channel where the data.contact resides in. |
| data.contact | object | Contact to whom the message was sent but not delivered. |
| data.message | object | Messages which was sent, will contain only message.id. |
| data.error.code | number | Error code, see errors below. |
| data.error.message | string | Detail message of an error, see errors below. |
Errors
Section titled “Errors”| Error Code | Reason |
|---|---|
| 1 | Error while processing the request. |
| 4 | Message failed to be delivered within 24 hours. |
Mobile (SMS): Message Echo
Section titled “Mobile (SMS): Message Echo”Message echo event is invoked whenever message is sent to user. This callback allows you to track all messages being sent no matter if they’re sent by you or by someone else.
{ "event": "message_echo", "timestamp" : "2017-12-29T17:26:17.331Z", "data" : { "id": "6456078996108088196", "channel": { "id": "6456078759331238786", "type": "mobile" }, "contact": { "id": "6456078781510718339", "phone_number": "15558576309" }, "content": { "type": "text", "payload": "We know, we try really hard to bring always something more to our great users!" }, "metadata": { "any": "arbitrary data" } }}| Parameter | Type | Description |
|---|---|---|
| data | object | Object representing message which is echoed. Different type of messages can be received (text, image, etc.). The structure matches Send Message response body. |
RCS Business Messages: Overview
Section titled “RCS Business Messages: Overview”See general webhook documentation for instructions on how to set up webhooks for your app and further details. This section will walk you through all common webhooks as well as webhooks specific to RBM platform.
RCS Business Messages: Message Received
Section titled “RCS Business Messages: Message Received”This event is fired whenever a reply from a contact is received.
{ "event": "message_received", "timestamp": "2016-10-06T13:42:48Z", "data": { "id": "6456078996108088196", "channel": { "id": "6456078759331238786", "type": "rbm" }, "contact": { "id": "6456078781510718339", "phone_number": "15558576309" }, "content": { "type": "text", "payload": "That's really nice that I can write you here. You guys rock!" }, "nlp": {...} }}| Parameter | Type | Description |
|---|---|---|
| data | object | Object representing message received. The structure matches Send Message response structure except for the nlp key which is valid only for received messages. |
Telegram: Overview
Section titled “Telegram: Overview”Same as Mobile (SMS): Overview.
Telegram: Message Received
Section titled “Telegram: Message Received”This event is fired whenever a contact sends a message to your Telegram Bot.
{ "event": "message_received", "timestamp": "2019-07-11T15:55:46.159Z", "data": { "id": "6555112239941832518", "contact": { "id": "6555112211957436097", "name": "Han Solo" }, "channel": { "id": "6555093381403135744", "type": "telegram" }, "content": { "payload": "Hello", "type": "text" }, "nlp": {...} }}| Parameter | Type | Description |
|---|---|---|
| data | object | Object representing message received. Different type of messages can be received (text, image, etc.). The structure matches Send Message response structure except for the nlp key which is valid only for received messages. |
| data.contact | object | Check Contact for fields description. |
Telegram: Message Echo
Section titled “Telegram: Message Echo”Message echo event is invoked whenever message is sent to user. This callback allows you to track all messages being sent no matter if they’re sent by you or by someone else.
{ "event": "message_echo", "timestamp": "2016-10-06T13:42:48Z", "data": { "id": "6456078996108099701", "channel": { "id": "6456078759331248741", "type": "telegram" }, "contact": { "id": "6456078781510715474" }, "content": { "type": "text", "payload": "We know, we try really hard to bring always something more to our beloved customers!" }, "metadata": { "any": "arbitrary data" } }}| Parameter | Type | Description |
|---|---|---|
| data | object | Object representing message which is echoed. Different type of messages can be received (text, image, etc.). The structure matches Send Message response body. |
Telegram: Postback Received
Section titled “Telegram: Postback Received”This event occurs when the user presses a Postback Button (which can be a part of a Structured Message). You can react to this event by performing an action or by sending a reply.
{ "event": "postback", "timestamp": "2020-03-01T15:49:02.243Z", "data": { "channel": { "id": "6456078759331238786", "type": "telegram" }, "contact": { "id": "6456078781510718339" }, "postback": { "payload": "{{DEVELOPER_DEFINED_PAYLOAD}}" } }}| Parameter | Type | Description |
|---|---|---|
| postback.payload | string | Payload of the Postback Button that has been pressed. |
Viber Bot: Overview
Section titled “Viber Bot: Overview”See general webhook documentation for instructions on how to set up webhooks for your app and further details. This section will walk you through all common webhooks as well as webhooks specific to Viber platform.
Viber Bot: Message Received
Section titled “Viber Bot: Message Received”This event is fired whenever a contact sends a message to your Viber Bot account.
📘 Amio Persists Message Files
All incoming messages having a file url attachments (i.e. Image Message, Video Message , etc.) are persisted on Amio servers due to expiration reasons.
{ "event": "message_received", "timestamp": "2016-10-06T13:42:48Z", "data": { "id": "6456078996108088196", "channel": { "id": "6456078759331238786", "type": "viber" }, "contact": { "id": "6456078781510718339" }, "content": { "type": "text", "payload": "That's really nice that I can write you here. You guys rock!" }, "nlp": {...} }}| Parameter | Type | Description |
|---|---|---|
| data | object | Object representing message received. Different type of messages can be received (text, image, etc.). The structure matches Send Message response structure except for the nlp key which is valid only for received messages. |
Viber Bot: Messages Delivered
Section titled “Viber Bot: Messages Delivered”This event notifies you of messages that were delivered to your contact.
{ "event": "messages_delivered", "timestamp" : "2017-12-29T17:26:17.331Z", "data" : { "channel": { "id": "6456078759331238786", "type": "viber" }, "contact": { "id": "6456078781510718339" }, "messages": [ { "id": "6456078996108088196" }, { "id": "6456079002382766981" } ], "delivered_timestamp": "2017-12-29T17:26:16.001Z" }}| Parameter | Type | Description |
|---|---|---|
| data.channel | object | Channel where the data.contact resides in. |
| data.contact | object | Contact to whom the messages were delivered. |
| data.messages | array | Array of messages that were delivered. Every message will contain message.id. |
| data.delivered_timestamp | string | Iso 8601 Timestamp. The time when Amio servers received notification about message delivery. This value may vary from webhook timestamp attribute due to delays. |
Viber Bot: Messages Read
Section titled “Viber Bot: Messages Read”This event occurs when a message has been read by the contact.
{ "event": "messages_read", "timestamp" : "2017-12-29T17:26:17.331Z", "data" : { "channel": { "id": "6456078759331238786", "type": "viber" }, "contact": { "id": "6456078781510718339" }, "last_read_timestamp": "2017-12-29T17:26:27.346Z" }}| Parameter | Type | Description |
|---|---|---|
| data.channel | object | Channel where the data.contact resides in. |
| data.contact | object | Contact that has read messages delivered. |
| last_read_timestamp | string | Iso 8601 Timestamp All messages that were sent before this timestamp were read. (It doesn’t mean “time when the messages were read”.) |
Viber Bot: Message Failed
Section titled “Viber Bot: Message Failed”This event notifies you of a message that could not be delivered to the recipient. See Viber documentation for details.
{ "event": "message_failed", "timestamp" : "2017-12-29T17:26:17.331Z", "data" : { "channel": { "id": "6456078759331238786", "type": "viber" }, "contact": { "id": "6456078781510718339" }, "message": { "id": "6456078996108088196" }, "error": { "code": 1, "message": "Error while processing the request." } }}| Parameter | Type | Description |
|---|---|---|
| data.channel | object | Channel where the data.contact resides in. |
| data.contact | object | Contact to whom the message was sent but not delivered. |
| data.message | object | Messages which was sent, will contain only message.id. |
| data.error.code | number | Error code, see errors below. |
| data.error.message | string | Detail message of an error, see errors below. |
Errors
Section titled “Errors”| Error Code | Reason |
|---|---|
| 1 | Error while processing the request. |
| 2 | Sending messages to this user is blocked. |
| 3 | Cannot find user for given phone number. |
| 4 | Message failed to be delivered within 24 hours. |
Viber Bot: Message Echo
Section titled “Viber Bot: Message Echo”Message echo event is invoked whenever a message is sent to a contact. This callback allows you to track all messages being sent no matter if they’re sent by your channel or any other channel with the same Viber Bot account.
{ "event": "message_echo", "timestamp": "2016-10-06T13:42:48Z", "data": { "id": "6456078996108088196", "channel": { "id": "6456078759331238786", "type": "viber" }, "contact": { "id": "6456078781510718339" }, "content": { "type": "text", "payload": "We know, we try really hard to bring always something more to our beloved customers!" }, "metadata": { "any": "arbitrary data" } }}| Parameter | Type | Description |
|---|---|---|
| data | object | Object representing message which is echoed. Different type of messages can be received (text, image, etc.). The structure matches Send Message response body. |
Viber Bot: Postback Received
Section titled “Viber Bot: Postback Received”This callback occurs when the user presses Postback Button. You can use this event to perform certain action or to send a reply.
{ "event": "postback", "timestamp": "2017-03-01T15:49:02.243Z", "data": { "channel": { "id": "6456078759331238786", "type": "viber" }, "contact": { "id": "6456078781510718339" }, "postback": { "payload": "{{PASS_THROUGH_PARAM}}" } }}| Parameter | Type | Description |
|---|---|---|
| payload | string | Developer-defined data set in Postback Button. |
Viber Business Messages: Overview
Section titled “Viber Business Messages: Overview”See general webhook documentation for instructions on how to set up webhooks for your app and further details. This section will walk you through all common webhooks as well as webhooks specific to Viber Business Messages platform.
Viber Business Messages: Message Received
Section titled “Viber Business Messages: Message Received”This event is fired whenever a reply from a contact is received.
{ "event": "message_received", "timestamp": "2016-10-06T13:42:48Z", "data": { "id": "6456078996108088196", "channel": { "id": "6456078759331238786", "type": "viber_business_messages" }, "contact": { "id": "6456078781510718339", "phone_number": "15558576309" }, "content": { "type": "text", "payload": "That's really nice that I can write you here. You guys rock!" }, "nlp": {...} }}| Parameter | Type | Description |
|---|---|---|
| data | object | Object representing message received. The structure matches Send Message response structure except for the nlp key which is valid only for received messages. |
Viber Business Messages: Messages Delivered
Section titled “Viber Business Messages: Messages Delivered”This event notifies you of messages that were delivered to your contact.
{ "event": "messages_delivered", "timestamp" : "2017-12-29T17:26:17.331Z", "data" : { "channel": { "id": "6456078759331238786", "type": "viber_business_messages" }, "contact": { "id": "6456078781510718339", "phone_number": "15558576309" }, "messages": [ { "id": "6456078996108088196" }, { "id": "6456079002382766981" } ], "delivered_timestamp": "2017-12-29T17:26:16.001Z" }}| Parameter | Type | Description |
|---|---|---|
| data.channel | object | Channel where the data.contact resides in. |
| data.contact | object | Contact to whom the messages were delivered. |
| data.messages | array | Array of messages that were delivered. Every message will contain message.id. |
| data.delivered_timestamp | string | Iso 8601 Timestamp. The time when Amio servers received notification about message delivery. This value may vary from webhook timestamp attribute due to delays. |
Viber Business Messages: Messages Read
Section titled “Viber Business Messages: Messages Read”This event occurs when a message has been read by the contact.
{ "event": "messages_read", "timestamp" : "2017-12-29T17:26:17.331Z", "data" : { "channel": { "id": "6456078759331238786", "type": "viber_business_messages" }, "contact": { "id": "6456078781510718339", "phone_number": "15558576309" }, "last_read_timestamp": "2017-12-29T17:26:27.346Z" }}| Parameter | Type | Description |
|---|---|---|
| data.channel | object | Channel where the data.contact resides in. |
| data.contact | object | Contact that has read messages delivered. |
| last_read_timestamp | string | Iso 8601 Timestamp All messages that were sent before this timestamp were read. (It doesn’t mean “time when the messages were read”.) |
Viber Business Messages: Message Failed
Section titled “Viber Business Messages: Message Failed”This event notifies you of a message that could not be sent using phone number. This happens mostly when there is no Viber account associated with a given phone number.
{ "event": "message_failed", "timestamp" : "2017-12-29T17:26:17.331Z", "data" : { "channel": { "id": "6456078759331238786", "type": "viber_business_messages" }, "contact": { "id": "6456078781510718339", "phone_number": "15558576309" }, "message": { "id": "6456078996108088196" }, "error": { "code": 3, "message": "Cannot find Viber user for given phone number." } }}| Parameter | Type | Description |
|---|---|---|
| data.channel | object | Channel where the data.contact resides in. |
| data.contact | object | Contact to whom the message was sent but not delivered. |
| data.message | object | Messages which was sent, will contain only message.id. |
| data.error.code | number | Error code, see errors below. |
| data.error.message | string | Detail message of an error, see errors below. |
Errors
Section titled “Errors”| Error Code | Reason |
|---|---|
| 1 | Error while processing the request. |
| 2 | Sending messages to this user is blocked. |
| 3 | Cannot find user for given phone number. |
| 4 | Message failed to be delivered within specified time (see channel property default_message_ttl). |
Viber Business Messages: Message Echo
Section titled “Viber Business Messages: Message Echo”Message echo event is invoked whenever a message is sent to a contact.
{ "event": "message_echo", "timestamp": "2016-10-06T13:42:48Z", "data": { "id": "6456078996108088196", "channel": { "id": "6456078759331238786", "type": "viber_business_messages" }, "contact": { "id": "6456078781510718339", "phone_number": "15558576309" }, "content": { "type": "text", "payload": "We know, we try really hard to bring always something more to our beloved customers!" }, "metadata": { "any": "arbitrary data" } }}| Parameter | Type | Description |
|---|---|---|
| data | object | Object representing message which is echoed. Different type of messages can be received (text, image, etc.). The structure matches Send Message response body. |
WhatsApp: Overview
Section titled “WhatsApp: Overview”See general webhook documentation for instructions on how to set up webhooks for your app and further details. This section will walk you through all common webhooks as well as webhooks specific to WhatsApp platform.
WhatsApp: Message Received
Section titled “WhatsApp: Message Received”This event is fired whenever a reply from a contact is received.
🚧 Contact Phone Number
The field
data.contact.phone_numberwill only be present in the webhook if the contact is responding to a message that was previously sent using a phone number (a template message).WhatsApp never shares anyone’s phone number.
{ "event": "message_received", "timestamp": "2016-10-06T13:42:48Z", "data": { "id": "6456078996108088196", "channel": { "id": "6456078759331238786", "type": "whatsapp" }, "contact": { "id": "6456078781510718339", "phone_number": "15558576389", "platform_id": "15558576389", "name": "Han Solo" }, "content": { "type": "text", "payload": "That's really nice that I can write you here. You guys rock!", "quick_reply": { "payload": "DEVELOPER_DEFINED_PAYLOAD" } }, "nlp": {...} }}| Parameter | Type | Description |
|---|---|---|
| data | object | Object representing message received. The structure matches Message response structure except for the nlp key which is valid only for received messages. |
| data.contact | object | Check Contact for fields description. |
| data.content | object | You can receive: - Text - Image - Audio - File - Video - Location |
| data.content.quick_reply | object | Only present when the message was created by the user tapping a Quick Reply button. Contains payload field which is used to identify which Quick Reply button was tapped. |
WhatsApp: Messages Delivered
Section titled “WhatsApp: Messages Delivered”This event notifies you of messages that were delivered to your contact.
{ "event": "messages_delivered", "timestamp" : "2017-12-29T17:26:17.331Z", "data" : { "channel": { "id": "6456078759331238786", "type": "whatsapp" }, "contact": { "id": "6456078781510718339", "phone_number": "15558576309", "platform_id": "15558576389", "name": "Han Solo" }, "messages": [ { "id": "6456078996108088196" }, { "id": "6456079002382766981" } ], "delivered_timestamp": "2017-12-29T17:26:16.001Z" }}| Parameter | Type | Description |
|---|---|---|
| data.channel | object | Channel where the data.contact resides in. |
| data.contact | object | Contact to whom the messages were delivered. |
| data.contact | object | Check Contact for fields description. |
| data.messages | array | Array of messages that were delivered. Every message will contain message.id. |
| data.delivered_timestamp | string | Iso 8601 Timestamp. The time when Amio servers received notification about message delivery. This value may vary from webhook timestamp attribute due to delays. |
WhatsApp: Messages Read
Section titled “WhatsApp: Messages Read”This event occurs when a message has been read by the contact.
{ "event": "messages_read", "timestamp" : "2017-12-29T17:26:17.331Z", "data" : { "channel": { "id": "6456078759331238786", "type": "whatsapp" }, "contact": { "id": "6456078781510718339", "phone_number": "15558576309", "platform_id": "15558576389", "name": "Han Solo" }, "last_read_timestamp": "2017-12-29T17:26:27.346Z" }}| Parameter | Type | Description |
|---|---|---|
| data.channel | object | Channel where the data.contact resides in. |
| data.contact | object | Contact that has read messages delivered. |
| data.contact | object | Check Contact for fields description. |
| last_read_timestamp | string | Iso 8601 Timestamp All messages that were sent before this timestamp were read. (It doesn’t mean “time when the messages were read”.) |
WhatsApp: Message Failed
Section titled “WhatsApp: Message Failed”This event is received when a message sent by your business failed. You can prepare for all kinds of errors by checking the WhatsApp list of errors.
{ "event": "message_failed", "timestamp" : "2017-12-29T17:26:17.331Z", "data" : { "channel": { "id": "6456078759331238786", "type": "whatsapp" }, "contact": { "id": "6456078781510718339", "phone_number": "15558576309", "platform_id": "15558576389", "name": "Han Solo" }, "message": { "id": "6456078996108088196" }, "error": { "code": 470, "message": "Message failed to send because more than 24 hours have passed since the customer last replied to this number. Use a message template to respond." } }}| Parameter | Type | Description |
|---|---|---|
| data.channel | object | Channel where the data.contact resides in. |
| data.contact | object | Contact to whom the message was sent but not delivered. Check Contact for fields description. |
| data.message | object | Messages which were sent. They will contain only message.id. |
| data.error.code | number | Error code, see WhatsApp error codes for more info. |
| data.error.message | string | The detail description of the error. |
WhatsApp: Postback Received
Section titled “WhatsApp: Postback Received”This event occurs when the user presses a Postback Button (which is a part of a Structured Message). You can react to this event by performing an action or by sending a reply.
{ "event": "postback", "timestamp": "2020-03-01T15:49:02.243Z", "data": { "channel": { "id": "6456078759331238786", "type": "whatsapp" }, "contact": { "id": "6456078781510718339", "phone_number": "15558576309", "platform_id": "15558576389", "name": "Han Solo" }, "postback": { "payload": "{{DEVELOPER_DEFINED_PAYLOAD}}" } }}| Parameter | Type | Description |
|---|---|---|
| postback.payload | string | Payload of the Postback Button that has been pressed. |