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

Webhook Quickstart



Create a Sink instance

create-a-sink-instance page anchor
(warning)

Warning

You will need to install and set up the Twilio CLI for your account to use the following command.

To create a new Webhook Sink, run this command:


_10
twilio api:events:v1:sinks:create --description <add sink description here> \
_10
--sink-configuration '{"destination":"${your webhook endpoint}","method":"${POST or GET}"}' \
_10
--sink-type webhook

(information)

Info

If we are unable to deliver events to your Sink due to a problem with the Sink, we send errors through Twilio Debugger. After the first error about Sink failure, we will continue to notify you every 20 minutes. The notification will include the Sink ID and error details.


Subscribe to Twilio events

subscribe-to-twilio-events page anchor

Now that you have a created Webhook Sink, you can subscribe to one or more events. Below are some of the available events. You can also view a full list of available events.

Event TypeSchema Version
com.twilio.voice.insights.call-summary.partial1
com.twilio.voice.insights.call-summary.predicted-complete1
com.twilio.voice.insights.call-summary.complete1

You can subscribe to any of these events by making an API call. This is done with the following command. The new subscription is configured to read the event-types from the --types argument — you'll need the event type and schema version from the table above. The event-types you specify in the--types argument will be sent to the Sink specified by the --sink-sid argument. Use the Sink SID of the Sink you created above.


_10
twilio api:events:v1:subscriptions:create --description <description> \
_10
--sink-sid <sink id DGxxx> \
_10
--types '{"type": "<event_type>","schema_version": <version>}'

For instance, to subscribe to all call summary events, you would run:


_10
twilio api:events:v1:subscriptions:create \
_10
--description "Subscription on 3 call_summary events" \
_10
--sink-sid <sink id DGxxx> \
_10
--types '{"type":"com.twilio.voice.insights.call-summary.partial","schema_version":1}' \
_10
--types '{"type":"com.twilio.voice.insights.call-summary.predicted-complete","schema_version":1}' \
_10
--types '{"type":"com.twilio.voice.insights.call-summary.complete","schema_version":1}'


Data is sent to the webhook sinks as a JSON array of CloudEvents(link takes you to an external page) with one event sent per webhook.

Here's a Voice Insights Call Summary Predicted Complete event, for example:


_10
{
_10
"specversion": "1.0",
_10
"type": "com.twilio.voice.insights.call-summary.predicted-complete",
_10
"source": "/v1/Voice/CA00000000000000000000000000000000/Summary",
_10
"id": "EZ00000000000000000000000000000000",
_10
"dataschema": "https://events-schemas.twilio.com/VoiceInsights.CallSummary/1",
_10
"datacontenttype": "application/json",
_10
"time": "2020-07-23T22:56:33.000Z",
_10
"data": "{\"call_sid\":\"CA00000000000000000000000000000000\",\"account_sid\":\"AC00000000000000000000000000000000\",\"parent_call_sid\":\"\",\"parent_account_sid\":\"\",\"start_time\":\"2020-07-23T22:56:28Z\",\"end_time\":\"2020-07-23T22:56:33Z\",\"duration\":0,\"connect_duration\":0,\"call_type\":\"client\",\"call_state\":\"canceled\",\"from\":{\"caller\":\"+55555555\",\"callee\":\"\",\"carrier\":\"MEGA:CORP\",\"connection\":\"landline\",\"number_prefix\":\"5555\",\"location\":{\"lat\":0.0,\"lon\":-0.0},\"city\":\"\",\"country_code\":\"US\",\"country_subdivision\":\"\",\"ip_address\":\"\",\"sdk\":null},\"to\":{\"caller\":\"\",\"callee\":\"client:SOMECLIENT\",\"carrier\":\"\",\"connection\":\"twilio_sdk\",\"number_prefix\":\"\",\"location\":null,\"city\":\"\",\"country_code\":\"\",\"country_subdivision\":\"\",\"ip_address\":\"\",\"sdk\":null},\"processing_state\":\"partial\",\"processing_version\":1,\"sip_edge\":null,\"carrier_edge\":null,\"sdk_edge\":null,\"client_edge\":null,\"tags\":[],\"attributes\":null,\"properties\":{\"q850_cause\":0,\"last_sip_response_num\":0,\"pdd_ms\":0,\"route_id\":\"\",\"media_region\":\"unknown_realm\",\"signaling_region\":\"unknown_realm\",\"twilio_media_ip\":\"\",\"twilio_signaling_ip\":\"\",\"external_media_ip\":\"\",\"external_signaling_ip\":\"\",\"sip_call_id\":\"\",\"user_agent\":\"\",\"selected_region\":\"unknown_realm\",\"region\":\"unknown_realm\",\"trunk_sid\":\"\",\"disconnected_by\":\"unknown_disconnected_by\",\"direction\":\"outbound_api\",\"settings\":null}}"
_10
}

The data field should meet its schema, which is the Voice Insights Call Summary schema(link takes you to an external page) in this case.


Rate this page: