Twilio Function Templates
Twilio Functions are a serverless environment to build and run Twilio applications so you can get to production faster. You provide the Node.js code to perform the task you need and Twilio runs it. You can read more about Twilio Functions and how to use them in the introductory blog post.
This repo is intended to be a collection of useful Twilio Functions that are tested and documented. The intention is that you can take any of these Functions and drop them into a project, confident they will work. Whether you are a developer looking for a particular building block or a builder who justs needs a particular Function. These templates are also available through
twilio-run new inside the
Each Function lives in its own directory within this repo. To use the code, copy the contents of the main Function file to your Twilio Function. Make sure you read the Function README so that you know which environment variables to set and the parameters the Function takes when you make HTTP requests to it.
This is the list of Functions available in this repo:
- Blank Template - Barebones template to get started
- Hello World - A very basic Function to get this repo started
- Hello Voice - Function to get you started with Twilio Prog. Voice
- Hello Messaging - Function to get you started with Twilio Prog. Messaging
- Forward Call - Forwards an incoming call to another number
- Forward Message - Forward incoming SMS messages to another number
- Forward Message to Multiple Numbers - Forwards incoming messages to a set of numbers
- Forward Message to Email via SendGrid - Uses SendGrid to forward incoming messages via email
- Forward Message to Email via Sparkpost - Uses Sparkpost to forward incoming messages via email
- Hunt/Find me - Call a list of numbers in order until one answers
- Generate Video access token - Generates a Video Access Token for client-side applications
- Generate Sync access token - Generates a Sync Access Token for client-side applications
- Generate Chat access token - Generates a Chat Access Token for client-side applications
- Conference line - Simple TwiML to drop callers into a conference call called "Snowy Owl"
- Simple play - TwiML to
- HTTP Redirect - Redirects a request from Twilio Functions to another URL by setting the Location header to the respective URL
- Temp Storage - Function that shows you where files created in a Twilio Function go and how to manage them for one-off activities
- Forward message to email with other API providers
- Generate Twilio Client access token
- Inbound calls for SIP registration
- Outbound calls for SIP registration
- Translate webhook from
application/jsonand forward on to another service
Please add ideas if you have them.
Pull requests and new Functions are accepted. To make a contribution, follow these steps:
- Fork this repository ( https://github.com/twilio-labs/function-templates/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
This project and Twilio Functions use Node.js version 8.10. I recommend using nvm if you need to install multiple versions of Node.js. Clone or download the project, use the correct version of Node.js and install the dependencies:
nvm use npm install
Tests are written with Jest. Run them with:
MIT © Phil Nash