skitch-1.png

Sending an SMS using Twilio

Marketo Employee
Marketo Employee

Webhooks are a great way for Marketo to interact with external systems and interfaces.  Common use cases include leveraging 3rd party interfaces for de duplication, to enrich lead data, and to send SMS messages. Here's an example of doing the latter leveraging Twilio, a Launchpoint partner of Marketo. The documentation for sending SMS messages for Twilio is also available.

Side note: Launchpoint is a thriving ecosystem of corporate partners that are actively developing solutions that complement the Marketo Platform. It's worth a look!

First...sign up for a Twilio account, taking note of your authentication token, you'll need that for sending your SMS.

Next up, create your webhook. Head over to Admin --> Integration --> Webhooks and click "new"

skitch-1.png

Webhook Name: Twilio Webhook

Description: Send an SMS

URL: https://%AccountSID%:%AuthToken%@api.twilio.com/2010-04-01/Accounts/%%AuthToken%@api.twilio.com/2010-04-01/Accounts/%AccountSID%/Messages.json (note you'll have to replace "Account SID" and "AuthToken" with the values from your Twilio Account

Request Type: POST

Template: From=%Your Send Number%&To={{lead.Mobile Phone Number}}&Body={{lead.Twilio Message:default=Test Message}}

Request Token Encoding: jSON

Response Type: None

Notes

     You'll need to put in your own Account SID and Auth Token

     You'll need to procure a Twilio Phone number to send from

     I also added a response mapping, as you can see of the "error_code" into the "twilioError" (API name) field. More on this later.

Once you have your Webhook set up, you have access and use it in your campaigns! In my example, I've set up a simple form on a Marketo Landing Page (both responsive and standard) that accepts First Name, Last Name, Email, Mobile Phone Number, and asks for a Message (limited to 255 characters). The lead is submitted to Marketo, the following data is updated or inserted

First Name

Last Name

Email Address

Mobile Number

SMS Message - a new string custom field on the Marketo Lead called "Twilio Message"

Error - a new string custom field on the Marketo Lead called Twilio Error

The Form and the Marketo Landing Page

I created a simple Form soliciting the above information (except Twilio Error, obviously), all of which are required, and put that form on a landing page. It looks like this:

skitch-2.png

The Campaign

Then we can create a simple campaign that is triggered off of the form being submitted, and then simply calls the webhook.

The Campaign Smart List

skitch-3.png

The Campaign Flow:

skitch-4.png

Once you've got all of that in place, submit the form, and youll see that SMS come through.

skitch-5.png

skitch-6.png

You can verify the SMS was sent in two places

1. The results tab of the campaign

skitch-2.png

2. The Lead Details Activity Tab

skitch-1.png

Bonus round

Sometimes the SMS may fail, and you may want to monitor for that. To do that, You can create a simple campaign trigging off the value changed of the "Twilio Error" field where the new value is not null. For the flow step, you can send an alert anywhere you like.. to an admin a distribution list.. wherever.

Cool, right?

3490
7
7 Comments
Level 3

This looks great.

I have an event and want to let people know when the sessions start. Instead of using the form can you add to list and then call the webhook? This would be around 100 contacts.

Marketo Employee

Webhooks (all webhooks) can only be called from trigger campaigns. you could create a campaign that triggers off your leads being added to this list.. sends the webhook.. then removed leads from the list. Would that work?

In your example, I'm not sure what I need to use in the URL field of the webhook. It looks like there are two different URLs. Do they both need to be there?

Level 10 - Community Moderator

It's one URL, Mike (/2010-04-01/Accounts/{AccountSid}/Messages).

It looks confusing because of the way the forum highlights URLs if they're not set to Plain Text.

Thanks Sanford! Appreciated!!

This is great info. I am looking to take it a bit further sending mass sms with Twilio and tracking the 2-way communication. Does anyone have any insight/case studies/documentation that would be helpful? Thanks!

Level 1

@Benjamin_Ortiz1  I came across this article while trying to set up my Twilio webhook, and though it's been years since you posted, hopefully this information will help someone.

To view the 2-way communication within Twilio, within Salesforce (which we are using), it was necessary to use the Messaging Service SID in the From parameter instead of the Phone Number.  Eg, From=<MessagingServiceSIDhere>&To=%2B1{{company.Mobile}}&Body={{my.SMS Message}}

You can find your Messaging Services including the Messaging Service SID for each on your Messaging Services page here: https://www.twilio.com/console/sms/services