Transcribing Voice Messages to Tasks with the Twilio Library for Salesforce

This week (Tuesday September 17 – Thursday September 19 2013), our friends at Twilio will be hosting TwilioCon – their annual cloud communications extravaganza. We’ll be there as an event sponsor, which prompted me to look back at my past integrations of Twilio with Force.com, and come up with a new one.

This time round, I’m going to use Twilio’s Transcription feature to record a voice message, transcribe it to text, look up a contact based on the caller ID and create a Task with the message transcription.

Here’s how I got this working…

The first step was to create a simple TwiML file in Visualforce; this acts as the script when a user dials my Twilio number:

When the call connects, my app says “Hello! Please leave a message”, beeps, and the caller has two minutes of message time (this is the maximum message length if you want the message transcribed). When the call completes, the incoming caller ID and a transcription of the call is sent (via an HTML form post) to the given transcribeCallback URL.

UPDATE: I added a link to the message recording at Twilio – very useful if the caller didn’t speak clearly and the transcription doesn’t make sense!

And that’s it – all done, in less than 40 lines of Apex.The last step was to create a Force.com Site, and make the MessageToTask endpoint publicly visible, as described in detail here. That gave me a publicly accessible endpoint with a URL of the form https://somesite.force.com/services/apexrest/messagetotask, which I set as the Voice Request URL in the Twilio developer console. A couple of quick calls confirmed that all was working as expected!

Here are a couple of messages logged against a Lead:

And here’s the detail of one of those:

Now that the Task is saved against the Lead, you’d likely want some Workflow or a Trigger to assign the Lead to a Queue for attention. I’ll leave that as an exercise for the reader 🙂

If you are at TwilioCon this week, stop by the Salesforce booth and you can try this out, ask questions about anything Salesforce-related, or just hang out with the Developer Relations team – we’d love to see you!

I have used the Twilio Salesforce helper library earlier and it worked great. However, it has not been updated for almost 2 years now and there are several new Twilio features missing – such as call queues, API queuing etc. which are difficult to use with current library code. Any plans to update the helper library in near future?