Twilio has a superb API for integrating SMS messages into your applications. It's easy to add Twilio as a remote HTTP service to any application you're building with DreamFactory. DreamFactory lets you securely store your Twilio authentication credentials, call the Twilio API directly from a DreamFactory session, and easily add role-based access control to any Twilio API endpoint. This brief tutorial shows you how to add Twilio to DreamFactory in five minutes.
If you don't already have a Twilio account, sign for a free account here.
If you don't have a DreamFactory instance, sign up for a free developer account here or install DreamFactory from Bitnami or GitHub.
Read more about Integrating GitHub here.
Navigate to the 'Services' tab of the DreamFactory Admin Console and follow the steps below to set up a secure connection to Twilio.
Now that Twilio is configured in DreamFactory, you can use any REST client to access Twilio API endpoints using the DreamFactory REST API. For example, here's how it works with cURL.
curl -i -k -3 -X POST "https://localhost:8080/api/v2/system/admin/session" -d '{ "email" : "you@you.com", "password" : "your_password" }' -H "Content-Type: application/json"
curl -i -k -3 -X GET "https://localhost:8080/api/v2/twilio/Accounts/<your twilio account sid>.json" -H "X-DreamFactory-Api-Key: <api key for the admin app in the apps tab>" -H "X-DreamFactory-Session-Token: <session token returned by the login api call above>"
It's also easy to add a Swagger definition for Twilio. The Swagger definition documents the Twilio API and makes it easy to make live API calls right in the DreamFactory API docs. There's a Swagger 2.0 JSON definition for Twilio on GitHub here. Just copy and paste the JSON into the 'Service Definition' tab.
The other benefit of adding the Swagger definition is to add role-based access control to the Twilio API. In the 'Roles' tab of DreamFactory, simply grant or deny access to your Twilio API for one or more roles. You can even partition the Twilio API into multiple Swagger files with different endpoints and assign the Swagger endpoints to different roles, all under the same Twilio account. It's all up to you!
You can also implement server-side event scripts on any Twilio endpoint defined in the Swagger definition. This is a powerful way to add logic to any Twilio API request or response.
This brief tutorial should help you get started building great apps with the simplicity and power of DreamFactory and Twilio. Let us know what you build!