I’ve long been a Twilio fan – their API does a fine job abstracting away the details of telephony, so I, as a developer, can focus on writing great SMS and voice-oriented apps. Now, with the new Twilio Helper Library for Salesforce, it’s easier than ever to use that API from Force.com.

The official announcement has links to the library code on GitHubfull documentation, and more, but, when I got wind of the new library, I thought it might be fun to dive right in and write a simple SMS app on Force.com, allowing you to send messages from a Visualforce page:

First, let’s look at the code for the page:

No surprises there – just a simple form for sending an SMS via the page controller. Let’s look at that controller:

The action here is in the sendSMS() method – we create a Map containing the message parameters, send it via account.getSmsMessages().create(), and display confirmation that the message was sent. That’s it: message sent, job done.

Of course, this is only the merest scratch of the surface of the API – go check out the docs and see what you can do with Twilio on Force.com.

Get the latest Salesforce Developer blog posts and podcast episodes via Slack or RSS.

Add to Slack Subscribe to RSS