Supercharge your Twilio API calls with Add-ons
Time to read: 2 minutes
Twilio Add-ons let you supercharge your Twilio API calls with features and capabilities offered by other communications API’s. Let’s add some Add-ons to our account and see how these mashups let us build better apps with fewer API calls.
Activating your favorite Add-ons
Find Add-ons to add to your account by heading over to the new Twilio Marketplace section of the Console. In this post we’ll look at two of them, the Ekata Reverse Phone and the IBM Watson Message Sentiment Add-ons.
To activate the Ekata Reverse Phone and the IBM Watson Message Sentiment Add-ons, press the Install button.
For the Ekata Reverse Phone Add-on, make sure that the Use In Lookups checkbox is selected. For the IBM Watson Message Sentiment Add-on, make sure that the Use In Incoming SMS Message checkbox is selected.
Once both Add-ons are activated we’re ready to start using them.
No more spam or serial-fraudsters!
With the Ekata Reverse Phone Add-on we can retrieve additional historic phone number related data as part of a request to the Twilio Lookup API.
To tell Twilio we want this additional data all we need to do is pass the AddOns
parameter to the API specifying the unique names of the Add-ons to use.
For example, using the Twilio Node helper library you include an addOns
parameter with your Lookup request:
Twilio will do a phone number lookup and mash the results of that API request together with the result from the Ekata Reverse Phone API, placing that data into a property named add_ons
.
In this payload we can review info like, is this a commerical business, is this a prepaid number, who is associated with that number and if there are any historic warnings about this number.
Happy or sad customer SMS?
Programmatically receiving and responding to SMS messages can enable great customer experiences. However without appropriately determining the context of the message we can end up with a static experience that feels robotic to the user.
With the IBM Watson Message Sentiment Add-on you can perform sentiment analysis on every incoming message without making any changes to your application. Because we’ve enabled the Add-on we start getting the semantic analysis results automatically passed in the payload of every incoming SMS webhook request.
Grab the ibm_watson_sentiment
information out of the AddOns
property from the payload and use it to determine whether the message is positive, negative or neutral and even how strong the sentiment is so that you can reply accordingly.
Give it a try using Node.js by creating a new file called server.js
and dropping this code into it:
Install the application dependencies and start the server:
Run ngrok http 3000
in a separate window to expose your server to the public using ngrok. If you want to know more about ngrok you can read more here.
Wire up the Message Request URL of an SMS enabled Twilio Phone Number with your ngrok URL. Send a text message to that number and watch as your application responds with a contextually appropriate message.
Just the beginning
Awesome! We have now supercharged our API calls to improve our customers experience even more and all that with only a few changes. Checking for fraud and the sentiment of a message is just the beginning though. You can find more Add-ons in the Twilio Marketplace.
Interested in offering your own API in the Twilio Marketplace? Request an invite and we’ll get in touch with you.
I can’t wait to see what you build with the new Add-ons! Feel free to contact me on Twitter @dkundel or via email dkundel@twilio.com to tell me more about it.
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.