Want to learn more about how Twilio uses webhooks? Check out the Webhooks Hub in our developer documentation!
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.
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:
- ASP.NET MVC for C#
- Servlets and Spark for Java
- Express for Node.js
- Django and Flask for Python
- Rails and Sinatra for Ruby
- PHP can be used alone or with frameworks like Laravel, Symfony and YiiYii.
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.
Check out these tutorials that show you how to work with webhooks on a variety of platforms: