Programmable Chat has been deprecated and is no longer supported. Instead, we'll be focusing on the next generation of chat: Twilio Conversations. Find out more about the EOL process here.
If you're starting a new project, please visit the Conversations Docs to begin. If you've already built on Programmable Chat, please visit our Migration Guide to learn about how to switch.
A Channel Webhook resource describes a webhook target that is specific to a Channel. By default, events in a Programmable Chat instance are delivered to a webhook address that is specified for the whole Chat Service. However, you can use this resource to specify up to five unique webhook targets for each channel to handle exceptional cases.
The webhook target can be a Web URL or a Studio Flow.
The unique string that we created to identify the Channel Webhook resource.
^WH[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Account that created the Channel Webhook resource.
^AC[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Service the Channel Webhook resource is associated with.
^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Channel the Channel Webhook resource belongs to.
^CH[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The JSON string that describes how the channel webhook is configured. The configuration object contains the url
, method
, filters
, and retry_count
values that are configured by the create and update actions.
The date and time in GMT when the resource was created specified in ISO 8601 format.
POST https://chat.twilio.com/v2/Services/{ServiceSid}/Channels/{ChannelSid}/Webhooks
The {ChannelSid}
value can be the Channel's sid
or its unique_name
.
The SID of the Service with the Channel to create the Webhook resource under.
^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
application/x-www-form-urlencoded
The type of webhook. Can be: webhook
, studio
, or trigger
.
webhook
trigger
studio
The URL of the webhook to call using the configuration.method
.
The HTTP method used to call configuration.url
. Can be: GET
or POST
and the default is POST
.
GET
POST
The events that cause us to call the Channel Webhook. Used when type
is webhook
. This parameter takes only one event. To specify more than one event, repeat this parameter for each event. For the list of possible events, see Webhook Event Triggers.
A string that will cause us to call the webhook when it is present in a message body. This parameter takes only one trigger string. To specify more than one, repeat this parameter for each trigger string up to a total of 5 trigger strings. Used only when type
= trigger
.
The SID of the Studio Flow to call when an event in configuration.filters
occurs. Used only when type
is studio
.
^FW[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The number of times to retry the webhook if the first attempt fails. Can be an integer between 0 and 3, inclusive, and the default is 0.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function createChannelWebhook() {11const webhook = await client.chat.v212.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.channels("ChannelSid")14.webhooks.create({ type: "webhook" });1516console.log(webhook.sid);17}1819createChannelWebhook();
1{2"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"channel_sid": "ChannelSid",5"sid": "WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",6"type": "webhook",7"configuration": {8"url": "dummy",9"method": "GET",10"filters": [11"onMessageSent",12"onChannelDestroyed"13],14"retry_count": 215},16"date_created": "2016-03-24T21:05:50Z",17"date_updated": "2016-03-24T21:05:50Z",18"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks/WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"19}
GET https://chat.twilio.com/v2/Services/{ServiceSid}/Channels/{ChannelSid}/Webhooks/{Sid}
The {ChannelSid}
value can be the Channel's sid
or its unique_name
.
The SID of the Service with the Channel to fetch the Webhook resource from.
^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Channel the Channel Webhook resource to fetch belongs to. This value can be the Channel resource's sid
or unique_name
.
The SID of the Channel Webhook resource to fetch.
^WH[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function fetchChannelWebhook() {11const webhook = await client.chat.v212.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.channels("ChannelSid")14.webhooks("WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")15.fetch();1617console.log(webhook.sid);18}1920fetchChannelWebhook();
1{2"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"channel_sid": "ChannelSid",5"sid": "WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",6"type": "studio",7"configuration": {8"flow_sid": "FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"9},10"date_created": "2016-03-24T21:05:50Z",11"date_updated": "2016-03-24T21:05:50Z",12"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks/WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"13}
GET https://chat.twilio.com/v2/Services/{ServiceSid}/Channels/{ChannelSid}/Webhooks
The {ChannelSid}
value can be the Channel's sid
or its unique_name
.
The SID of the Service with the Channel to read the resources from.
^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
How many resources to return in each list page. The default is 50, and the maximum is 1000.
1
Maximum: 1000
The page token. This is provided by the API.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function listChannelWebhook() {11const webhooks = await client.chat.v212.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.channels("ChannelSid")14.webhooks.list({ limit: 20 });1516webhooks.forEach((w) => console.log(w.sid));17}1819listChannelWebhook();
1{2"meta": {3"page": 0,4"page_size": 5,5"first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks?PageSize=5&Page=0",6"previous_page_url": null,7"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks?PageSize=5&Page=0",8"next_page_url": null,9"key": "webhooks"10},11"webhooks": [12{13"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",14"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",15"channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",16"sid": "WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",17"type": "webhook",18"configuration": {19"url": "dummy",20"method": "GET",21"filters": [22"onMessageSent",23"onChannelDestroyed"24],25"retry_count": 226},27"date_created": "2016-03-24T21:05:50Z",28"date_updated": "2016-03-24T21:05:50Z",29"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks/WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"30},31{32"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",33"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",34"channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",35"sid": "WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",36"type": "trigger",37"configuration": {38"url": "dummy",39"method": "POST",40"filters": [41"keyword1",42"keyword2"43],44"retry_count": 345},46"date_created": "2016-03-24T21:05:50Z",47"date_updated": "2016-03-24T21:05:50Z",48"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks/WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"49},50{51"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",52"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",53"channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",54"sid": "WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",55"type": "studio",56"configuration": {57"flow_sid": "FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"58},59"date_created": "2016-03-24T21:05:50Z",60"date_updated": "2016-03-24T21:05:50Z",61"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks/WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"62}63]64}
POST https://chat.twilio.com/v2/Services/{ServiceSid}/Channels/{ChannelSid}/Webhooks/{Sid}
The {ChannelSid}
value can be the Channel's sid
or its unique_name
.
The SID of the Service with the Channel that has the Webhook resource to update.
^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Channel the Channel Webhook resource to update belongs to. This value can be the Channel resource's sid
or unique_name
.
The SID of the Channel Webhook resource to update.
^WH[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
application/x-www-form-urlencoded
The URL of the webhook to call using the configuration.method
.
The HTTP method used to call configuration.url
. Can be: GET
or POST
and the default is POST
.
GET
POST
The events that cause us to call the Channel Webhook. Used when type
is webhook
. This parameter takes only one event. To specify more than one event, repeat this parameter for each event. For the list of possible events, see Webhook Event Triggers.
A string that will cause us to call the webhook when it is present in a message body. This parameter takes only one trigger string. To specify more than one, repeat this parameter for each trigger string up to a total of 5 trigger strings. Used only when type
= trigger
.
The SID of the Studio Flow to call when an event in configuration.filters
occurs. Used only when type
= studio
.
^FW[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The number of times to retry the webhook if the first attempt fails. Can be an integer between 0 and 3, inclusive, and the default is 0.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function updateChannelWebhook() {11const webhook = await client.chat.v212.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.channels("ChannelSid")14.webhooks("WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")15.update({ "configuration.url": "Configuration.Url" });1617console.log(webhook.sid);18}1920updateChannelWebhook();
1{2"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"channel_sid": "ChannelSid",5"sid": "WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",6"type": "trigger",7"configuration": {8"url": "dummy",9"method": "POST",10"filters": [11"keyword1",12"keyword2"13],14"retry_count": 315},16"date_created": "2016-03-24T21:05:50Z",17"date_updated": "2016-03-24T21:05:51Z",18"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks/WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"19}
DELETE https://chat.twilio.com/v2/Services/{ServiceSid}/Channels/{ChannelSid}/Webhooks/{Sid}
The {ChannelSid}
value can be the Channel's sid
or its unique_name
.
The SID of the Service with the Channel to delete the Webhook resource from.
^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Channel the Channel Webhook resource to delete belongs to. This value can be the Channel resource's sid
or unique_name
.
The SID of the Channel Webhook resource to delete.
^WH[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function deleteChannelWebhook() {11await client.chat.v212.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.channels("ChannelSid")14.webhooks("WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")15.remove();16}1718deleteChannelWebhook();