Sending an SMS using Twilio

John_M
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?

11874
14
14 Comments
Sarah_Greig2
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.

John_M
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?

Michael_Mason
Level 4

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?

SanfordWhiteman
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.

Michael_Mason
Level 4

Thanks Sanford! Appreciated!!

Benjamin_Ortiz1
Level 4

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!

Jamie_Adams
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

 

simonwha
Level 1

Does the phone number on the lead record need to be in any sort of format? 

For example, if a phone number on a lead reads (444)333-2222 versus 444-333-2222, would it create any issues? 

SanfordWhiteman
Level 10 - Community Moderator

Hi Simon, can I ask you to open a new thread in Products (https://nation.marketo.com/t5/Products/ct-p/products)? That'll give better visibility than blog comments, which are frequently overlooked. Give a link back to this blog post for context.

Tyron_Pretorius
Level 9 - Champion

@Benjamin_Ortiz1 

 

While I have not used Twilio for SMS in Marketo, I have achieved 2 way SMS with Telnyx, Zapier, and Marketo and documented the setup in this blog post: https://theworkflowpro.com/marketo-sms-integration/ 

 

The post above will show you how to 

  • Parse the inbound SMS for keywords and choose an appropriate response
  • Send the SMS response to the customer and optional alerts to your team
  • Set the person's SMS subscription field in Marketo to TRUE or FALSE if the "STOP" or "START" keywords are present