Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

Webhook Configuration Resource


The Webhook Configuration resource allows you to precisely control the effects of account-scoped webhooks. Sending a POST request to the Webhook Configuration endpoint is equivalent to configuring session webhooks in the Twilio Console(link takes you to an external page).

Good applications of the configured webhooks in Conversations include:

  • Implementing an archival system for all Conversations
  • Feeding messages into Elasticsearch
  • Implementing a profanity filter across all Conversations

Note: You can send pre-hooks and post-hooks to different targets.

Our guide to Conversations Webhooks includes the specific pre- and post-event webhooks that fire, as well as the webhook payloads.


ConfigurationWebhook Properties

configurationwebhook-properties page anchor
Property nameTypePIIDescription
account_sidSID<AC>
Not PII

The unique ID of the Account responsible for this conversation.

Pattern: ^AC[0-9a-fA-F]{32}$Min length: 34Max length: 34

methodenum<string>

The HTTP method to be used when sending a webhook request.

Possible values:
GETPOST

filtersarray[string]

The list of webhook event triggers that are enabled for this Service: onMessageAdded, onMessageUpdated, onMessageRemoved, onConversationUpdated, onConversationRemoved, onParticipantAdded, onParticipantUpdated, onParticipantRemoved


pre_webhook_urlstring

The absolute url the pre-event webhook request should be sent to.


post_webhook_urlstring

The absolute url the post-event webhook request should be sent to.


targetenum<string>

The routing target of the webhook. Can be ordinary or route internally to Flex

Possible values:
webhookflex

urlstring<uri>

An absolute API resource API resource URL for this webhook.


Fetch a ConfigurationWebhook resource

fetch-a-configurationwebhook-resource page anchor
GET https://conversations.twilio.com/v1/Configuration/Webhooks

FETCH: Retrieve a Webhook Configuration Resource

fetch-retrieve-a-webhook-configuration-resource page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_18
// Download the helper library from https://www.twilio.com/docs/node/install
_18
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_18
_18
// Find your Account SID and Auth Token at twilio.com/console
_18
// and set the environment variables. See http://twil.io/secure
_18
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_18
const authToken = process.env.TWILIO_AUTH_TOKEN;
_18
const client = twilio(accountSid, authToken);
_18
_18
async function fetchConfigurationWebhook() {
_18
const webhook = await client.conversations.v1.configuration
_18
.webhooks()
_18
.fetch();
_18
_18
console.log(webhook.accountSid);
_18
}
_18
_18
fetchConfigurationWebhook();

Output

_12
{
_12
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_12
"pre_webhook_url": "https://example.com/pre",
_12
"post_webhook_url": "https://example.com/post",
_12
"method": "GET",
_12
"filters": [
_12
"onMessageSend",
_12
"onConversationUpdated"
_12
],
_12
"target": "webhook",
_12
"url": "https://conversations.twilio.com/v1/Configuration/Webhooks"
_12
}


Update a ConfigurationWebhook resource

update-a-configurationwebhook-resource page anchor
POST https://conversations.twilio.com/v1/Configuration/Webhooks

Request body parameters

request-body-parameters page anchor
Property nameTypeRequiredPIIDescription
MethodstringOptional

The HTTP method to be used when sending a webhook request.


Filtersarray[string]Optional

The list of webhook event triggers that are enabled for this Service: onMessageAdded, onMessageUpdated, onMessageRemoved, onConversationUpdated, onConversationRemoved, onParticipantAdded, onParticipantUpdated, onParticipantRemoved


PreWebhookUrlstringOptional

The absolute url the pre-event webhook request should be sent to.


PostWebhookUrlstringOptional

The absolute url the post-event webhook request should be sent to.


Targetenum<string>Optional

The routing target of the webhook.

Possible values:
webhookflex

UPDATE: Enable all Webhooks with filters

update-enable-all-webhooks-with-filters page anchor

Enable for 'onConversationUpdated' & 'onMessageRemoved' events

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_23
// Download the helper library from https://www.twilio.com/docs/node/install
_23
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_23
_23
// Find your Account SID and Auth Token at twilio.com/console
_23
// and set the environment variables. See http://twil.io/secure
_23
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_23
const authToken = process.env.TWILIO_AUTH_TOKEN;
_23
const client = twilio(accountSid, authToken);
_23
_23
async function updateConfigurationWebhook() {
_23
const webhook = await client.conversations.v1.configuration
_23
.webhooks()
_23
.update({
_23
filters: ["onConversationUpdated", "onMessageRemoved"],
_23
method: "POST",
_23
postWebhookUrl: "https://company.com/archive-every-action",
_23
preWebhookUrl: "https://company.com/filtering-and-permissions",
_23
});
_23
_23
console.log(webhook.accountSid);
_23
}
_23
_23
updateConfigurationWebhook();

Output

_11
{
_11
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_11
"pre_webhook_url": "https://company.com/filtering-and-permissions",
_11
"post_webhook_url": "https://company.com/archive-every-action",
_11
"method": "POST",
_11
"filters": [
_11
"onConversationUpdated"
_11
],
_11
"target": "webhook",
_11
"url": "https://conversations.twilio.com/v1/Configuration/Webhooks"
_11
}


Rate this page: