The power of variables in your SMS campaigns


We’ve been asked many times by our clients what would be the best way to integrate their current CRM so they can send customized and targeted SMS with a click, so we decided to write a post about what we offer in that sense. Let us start by first saying that the answer is just a word (which you might have guessed by now): “Variables!”.

What “Variables” are, and how they work

Variables are just a key/value pair, they don’t have a flashy name, but they are really powerful when used in the right way.

For example, one could have a variable named first_name with a value that will depend (and change) on how (and to whom) a message is sent. It could be Alice, Bob, Charlie, etc. The value will be filled in at the exact moment the message is being sent (or, as we’d like to call it, variables have a “late binding” nature).

So how to use them exactly? Oh let us count the number of ways!


We have always offered this feature for templates, and we have also dedicated a blog post about them. A template allows you to reuse a text by just interpolating variables in it. You can then send the template to a specific destination or to a group of contact lists. As an example, we could create a template with this text:

Hello {{first_name}}, your payment of ${{amount}} has been processed. Thanks for shopping with us!

What you see inside the double brackets (i.e: {{…}}) are variables. In this case we have two of them, named “first_name“, and “amount“.

When you send a message by using a template, you can specify the values for each one of the variables and we will just “fill in the blanks” and send a complete text, like:

Hello John, your payment of $79.99 has been processed. Thanks for shopping with us!

You can find documentation about how to use templates through our REST API and SDKs here:


Templates and variables work great, but it might be annoying to send some values that will never change over and over. For example, when sending a message to “John”, we might not want to specify that the variable “first_name” equals “John” with every message we send. The name for John will most likely never change (although nothing is 100% sure, right?).

That’s why we can set variables in “Contacts“. Contacts are just phone numbers (e.g: 13055702828), and we can set the variable “first_name” for the contact “13055702828” to the value “John”.

From then on, when sending a template to this number it is no longer necessary to specify that value, we can just specify the value for “amount”, (or any others) and all the variables values will be merged right before the message is sent. All the variables used in a template and available in the contacts will be used.

To know more about how to use variables for a specific contact through our REST API and SDKs, please see

So what if you want to export a list of customers from your CRM with all the needed (or standard) variables and then import it to PortaText? No problem! Just use a CSV file. Here’s the specific documentation on how to use a CSV file to assign variables to a bunch of contacts in a batch fashion:


And last but not least, we get to the what everyone wants: campaigns. And yes, you can use variables in your campaigns too! When creating a campaign you can choose a template to use for the message like the one we showed before. Variable values can be specified when creating the campaign and on each one of the contacts. We already know that.

But you can also choose to upload your targets via a CSV file, and add variables to each one of the contacts right there (usable only for the duration of the campaign). For example, one could choose to use a template to create a campaign and upload a CSV like this one:


13055702828, 79.99

When sending a message, the variable first_name will get its value from the contact, while the amount value will be set to the value specified in the CSV file for each contact.

To see the gory details about how to use campaigns, please see our REST API documentation at


We hope you enjoyed this small “tutorial” on the use of variables and hopefully the concept is now more clear so you can start taking advantage of it. With the use of variables and CSV files your current applications can be easily integrated and used to send really customized SMS to your clients.

For more information on how to use them please head to the REST API documentation, but don’t forget that we also offer several open source SDKs for different programming languages. If you have any questions, don’t hesitate to contact us! We’ll be glad to help 🙂

— The PortaText Team.