Skip to contentSkip to navigationSkip to topbar
Rate 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
Resource properties
account_sidtype: SID<AC>Not PII

The unique ID of the Account(link takes you to an external page) responsible for this conversation.


methodtype: enum<STRING>Not PII

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

Possible values:
GETPOST

filterstype: string[]Not PII

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


pre_webhook_urltype: stringNot PII

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


post_webhook_urltype: stringNot PII

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


targettype: enum<STRING>Not PII

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

Possible values:
webhookflex

urltype: string<URI>Not PII

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

Parameters

fetch-parameters page anchor

This action does not accept any parameters.

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

_11
// Download the helper library from https://www.twilio.com/docs/node/install
_11
// Find your Account SID and Auth Token at twilio.com/console
_11
// and set the environment variables. See http://twil.io/secure
_11
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_11
const authToken = process.env.TWILIO_AUTH_TOKEN;
_11
const client = require('twilio')(accountSid, authToken);
_11
_11
client.conversations.v1.configuration
_11
.webhooks()
_11
.fetch()
_11
.then(webhook => console.log(webhook.method));

Output

_12
{
_12
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_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
Methodtype: stringNot PII

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


Filterstype: string[]Not PII

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


PreWebhookUrltype: stringNot PII

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


PostWebhookUrltype: stringNot PII

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


Targettype: enum<STRING>Not PII

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

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

Output

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


Rate this Page: