📲 How to integrate Tape with Twilio to send SMS text messages

In various scenarios, reaching prospects or clients via email is not sufficient and you may want to make contact via SMS text messages instead to reach them directly on their cell phones. :calling:

This guide shows how to send an SMS text message via Twilio and Tape workflow automations. We will directly integrate Twilio via their API and use a workflow automation in Tape to dispatch the SMS.

Kudos to our awesome community for sharing your ideas and interest in this topic beforehand :blue_heart:


We start off from a contacts app that holds our prospects names and phone numbers. We want to allow users to dispatch an SMS to a user by creating a comment on the contact record in the format of

"sms:Urgent attention needed please call us back"

which will then yield an SMS with Urgent attention needed please call us back to the contact’s phone number.

Let’s get started with setting up the workflow.

Twilio account and API

In order to replicate the scenario depicted in this guide, you will need a proper Twilio account. You can test it using a free trial account as well.


After creating your account, you will be presented with the Twilio console. This is also where you will find your Account SID and your Auth token - both will be required to set up communication with Twilio:

We will need to compose these two into a value that can be used as Basic Authentication header. First, compose them in this format:

{account SID}:{auth token}

The result needs to be base 64 encoded. There are also online tools to achieve this, we would however not recommend using them for production secrets. An example is here.

Once you have your composed header secret, we can proceed.

A more detailed guide is provided e.g. by the Mautic docs:

API notes & insights

As stated here in the Twilio docs, the content type for requests needs to be application/x-www-form-urlencoded or multipart/form-data. As the second one is currently not available in Tape automations, we will use application/x-www-form-urlencoded which basically means sending params as key/value pairs, while URL encoding the keys and values and composing them as a string.

We will also need to set a proper content type header. The guide will show later show how all of this is done.

Creating the workflow automation

Create a workflow automation with the “Comment created” trigger and add a filter to only run if a comment starts with ‘sms:’ similar to this:

Next up, we will extract the message body from the comment body:


Your calculation might look like this:

We also store the recipient phone number from the field value variable:

Note that your variable names might be different, if your app / field has a different name. Remember to adjust the code accordingly.

We’re almost there - now we need to compose the request body. As stated above, we cannot just send a JSON, but need to compose an URL encoded key value string. We will use an Execute Script action to perform a two step process of composing and encoding a clean, maintainable and readable way:

Note that you need your own From address here. You will find it most easily using the Twilio API explorer.

Now, last step is to perform the POST HTTP request. We need to also set the content type header (remember from above) and the auth header composed before with the "Basic " prefix. The resulting action will look like this:

As we prepared things step by step, it looks rather clean now. The final workflow automation might look similar to this:

Try it out

That’s it - we set up a fully fledged Twilio SMS integration within a couple of minutes. :tada:

Adding a comment to the record will dispatch the SMS via Twilio - nice. Time to shoot some text messages :eyes:


As usual, let us know what you think, how this guide can be improved and if it works for you in the comments below :point_down:

Cheers &
Happy messaging



This is excellent, Tim! Thanks so much for putting this together.

When interacting with APIs who require JSON, it’s pretty straight forward how to format the request body but it’s nice now to have a good code example of how to form URL parameters when required.

I also highly recommend using Buffer when you need to base64 encode strings directly in Tape, and reiterate that it would be great to have a place to store encrypted keys in Automations and use them globally throughout many flows.

1 Like

How difficult would it be to integrate Twilio voice, I wonder?
For dialing out, and for displaying call recordings.

I am using CallRail, when sending the message I am pulling the content from a multiline text field. How can I strip the HTML tags but keep the formatting?

This will strip paragraphs and returns. If you have more in depth HTML This will have to be modified further. It should give you a good start though.

function stripHTML(html) {
    // Replace <br> and </p> tags with \n
    let text = html.replaceAll(/<br\s*\/?>/gi, "\n").replaceAll(/<\/p>/gi, "\n");
    // Strip out remaining HTML tags
    text = text.replaceAll(/<[^>]+>/g, '');
    return text;

let html = your_token_here;

That did it. Thank you!