Forward a URL encoded Twilio webhook event to a JSON webhook, suitable for use with services like Zapier and IFTTT.
Generally, this function template needs the URL for a publicly accessible webhook that can receive Twilio event data in a JSON format.
To push data to Zapier, you will need a Zapier account and a Zap with a Catch Hook webhook trigger.
To push data to IFFF, use an IFTTT Maker Webhook as a trigger for an action. The URL for your webhook will be available in the documentation page for IFTTT Maker Webhooks. By default, this function template exposes SMS SIDs, phone numbers, and text content to IFTTT.
This project requires some environment variables to be set. To keep your tokens and secrets secure, make sure to not commit the .env
file in git. When setting up the project with twilio serverless:init ...
the Twilio CLI will create a .gitignore
file that excludes .env
from the version history.
In your .env
file, set the following values:
Variable | Description | Required |
---|---|---|
WEBHOOK_URL | The URL for the webhook your function should push data to | Yes |
- Install the Twilio CLI
- Install the serverless toolkit
twilio plugins:install @twilio-labs/plugin-serverless
- Initiate a new project
twilio serverless:init example --template=json-webhook && cd example
- Start the server with the Twilio CLI:
twilio serverless:start
- Open the web page at https://localhost:3000/index.html and follow the instructions to test your application.
ℹ️ Check the developer console and terminal for any errors, make sure you've set your environment variables.
Deploy your functions and assets with either of the following commands. Note: you must run these commands from inside your project folder. More details in the docs.
With the Twilio CLI:
twilio serverless:deploy