CORE MODULE

Conditional Content for SMS

What you'll learn in this guide

‍How to personalise SMS messages with recipient data, swap content based on what's in your data file, and use a single template to send the right message to the right person — without juggling multiple campaigns.

Overview

SMS is the channel where every character has to earn its place. Personalisation isn't just a nice touch — it's how you make sure each message lands with the right information for the right person, without bloating your character count or running separate sends for every audience.

Conditional content lets you tailor what each recipient sees based on the data behind your send. That might be as simple as dropping in a first name, or as advanced as showing one message to customers with an overdue balance and a different one to those up to date, all from the same SMS template.

This guide walks through the syntax you'll reach for most often: personalisation tokens, personalised links, and Razor logic for conditional content.

Quick Tip
‍
SMS messages are limited to 160 characters per segment. Because dynamic fields and conditional content change the final length depending on the data, it's worth previewing a handful of recipient scenarios before you hit send.

‍

Insert personalised fields

Drop recipient data into your SMS using the %%FIELD_NAME%% syntax. The field name needs to match the source field in your data file exactly — not the label or description — and it's case-sensitive.

Here's how it looks in a message:

Hi %%FirstName%%, your appointment is confirmed for %%AppointmentDate%%.


When the SMS sends, those tokens are replaced with the actual values from your data, so each recipient sees their own details. If a field is missing or misspelled, nothing will merge in for that recipient — which is why it's worth double-checking field names against your data file before sending.

‍

Personalise links in your SMS

Links can be personalised the same way. Just drop your %%FIELD_NAME%% token inside the URL:

https://securesystem.clientname.com.au/%%TOKEN%%


This is handy for sending each recipient to their own page — a personalised statement, a portal login, a survey unique to them, or a one-time secure link.

‍‍

Heads up
‍
Razor syntax (@Model.Fields or @Model.Document) isn't supported inside URLs. Only the %%FIELD_NAME%% syntax works for link personalisation, so stick to that when you're building links.

‍

Use conditional logic with Razor

For anything beyond a straight field swap, Razor syntax lets you build logic into your SMS template. Razor uses the @Model object to access your data, and you can reach any field with:

@Model.Fields["FieldName"]


Use this inside Razor expressions whenever you need a field value — most commonly in an @if condition, which is where conditional content really earns its keep.

‍

Show different content with an if condition

An @if statement lets you check a value in your data and send different copy based on the result. Here's the pattern:

@if (Model.Fields["product"] == "productname") {    Variable content 1} else {    Variable content 2}


In plain English: if the product field in the data matches productname, the recipient sees the first piece of content. If not, they see the second. You can chain multiple conditions together using else if when you need more than two outcomes.

This is what lets you run one template across very different audiences. A single appointment reminder can say something different to first-time visitors than it does to returning customers, all driven by what's sitting in your data file.

‍

Access data from your document

If your data file includes more complex transactional content — like multiple statements, line items, or nested elements — you can reach into it using @Model.Document. The Document property gives you the XML of the original input file, and the Data node is where any complex or transactional data lives.

Here's what that data might look like:

<Document>
    <Fields>  <-- Accessible via Model.Fields["FieldName"] -->
        <StatementDate>2018-01-01</StatementDate>
        <CustNo>123456</CustNo>
    </Fields>
    <Data>  <-- Accessible via Model.Document.Element("Data") -->
        <Statement>
            <AccountNumber>123456</AccountNumber>
        </Statement>
    </Data>
</Document>


And here's how you'd pull a value from that Data node:

@{
    var dataNode = Model.Document.Element("Data");
    foreach (XElement statement in dataNode.Descendants("Statement")) {
        @statement.Element("AccountNumber").Value
    }
}


For SMS, you'll typically use this to surface a single relevant value — like the most recent account number or balance — rather than looping through long lists. Your character count won't thank you for trying to fit a full statement summary into 160 characters.

Quick recap

That's the toolkit. For most SMS messages, %%FIELD_NAME%% will do the heavy lifting — dropping names, dates, reference numbers, and personalised links into your copy. Razor comes into play when you need real logic: different messages for different scenarios, all from one template.

And before you send anything live, preview a few different recipient scenarios. Conditional content makes one template do the work of many, so it's worth checking each branch lands the way you'd expect.