Twilio Functions Now Supports npm
Time to read: 2 minutes
- Import third-party libraries into your functions using npm package manager.
- Leverage free, reusable code from the community.
- Available today in Twilio Functions.
Today, we’re excited to announce npm support for Twilio Functions. npm is a package manager for JavaScript that makes it easy to share and reuse code. With npm support in Twilio Functions, you can now leverage the ecosystem of packages and modules provided by the Node.js community.
npm support is the first addition in what we’re calling Twilio Functions Packages—a service of Twilio Functions that automatically retrieves, installs, and deploys the third-party packages you require. With Twilio Functions Packages, you never have to upload a package or library to Twilio. All of the logistics of package management is taken care of behind the scenes, so you can stay focused on putting them to work.
How to Install an npm Module
You can get started installing a npm module with a few simple steps:
- Start by heading over to the Configure page for Functions. Under the ‘Dependencies’ header you will find all of the currently installed NPM modules.
- Click the plus (“+”) button in the top-left hand corner of the table to add a new npm module. This will add a new row to the Dependencies table.
- Enter the name and version of the npm module you want to include in the new row.
- When you’re done, click ‘Save’. This will trigger a deployment of your functions.
That’s it—you’re done!
Once your deployment completes all of your functions will be able to access the new npm module. To start using this new npm module just use therequire()
method to include it in your function.
To minimize maintenance and support headaches, every change to the npm list will be deployed instantly, ensuring the function environment stays consistent and up-to-date.
Using npm in Functions
Developers can start using npm modules inside their functions by including them with the require()
method. Below is example of a function, including the SendGrid npm package to send an email.
See npm+Functions in action in the demo vid below:
Wrapping It Up
npm support is the latest in a long list of upcoming releases for Twilio Functions. We’re excited to see how developers use this new capability to prototype and build production-grade applications on top of Twilio. Below are some resources to get help you get started building:
- npm Support Documentation
- Twilio Functions in Console
- Features and Pricing
- Voice Quickstart
- FAQ
- Watch Twilio Functions Demo from SIGNAL [YouTube]
We can’t wait to see what you build with Twilio Functions and npm!
Related Posts
Related Resources
Twilio Docs
From APIs to SDKs to sample apps
API reference documentation, SDKs, helper libraries, quickstarts, and tutorials for your language and platform.
Resource Center
The latest ebooks, industry reports, and webinars
Learn from customer engagement experts to improve your own communication.
Ahoy
Twilio's developer community hub
Best practices, code samples, and inspiration to build communications and digital engagement experiences.