Webhooks are user-defined HTTP callbacks. They are triggered by some event in a web application and can facilitate integrating different applications or third-party APIs, like Twilio.

More on Webhooks

Twilio uses webhooks to let your application know when events happen, such as receiving an SMS message or getting an incoming phone call. When the event occurs, Twilio makes an HTTP request (usually a POST or a GET) to the URL you configured for the webhook. Twilio's request will include details of the event such as the incoming phone number or the body of an incoming message. Many other modern web services like GitHub and Slack also make use of webhooks to communicate events.

How webhooks work

To handle a webhook you only need to build a small web application that can accept the HTTP requests. If you already have a web application set up, handling a webhook is usually as easy as adding a new URL to your application.

If you don't already have a web application, almost all server-side programming languages offer frameworks to help you build one. Examples include:

Webhooks can also be handled by serverless frameworks like AWS Lambda and Azure Functions. Really anything that can receive and reply to an HTTP request will do. Got a Raspberry Pi lying around?

Whichever framework and language you choose, webhooks function the same for every Twilio application. An HTTP request will be made to a URI that you provide to Twilio. Your application performs whatever logic you feel necessary - read/write from a database, integrate with another API, or perform some computation - then replies to Twilio with a TwiML response with the instructions you want Twilio to perform.