Oops! Facing network problem. Unable to load this page. Refresh
SPRL

Just a moment...

Hello Guest

logo

FAQs

Help Center

WhatsApp Business API

Using Variables in Templates

Personalize WhatsApp messages using dynamic variables.

Overview

Variables allow you to personalise WhatsApp Template Messages by replacing placeholders with recipient-specific information when a message is sent. Instead of creating a separate template for every customer, you can use variables to insert names, order numbers, appointment dates, tracking IDs, and other dynamic values.

SPRL supports template variables for both WhatsApp campaigns and REST API messaging, making it easy to send personalised messages at scale.

Good to Know:
Variables are replaced with actual values when the message is sent. Each recipient can receive the same template with different personalised information.

Why Use Variables?

Without VariablesWith Variables
Create multiple templates for different recipients.Use one template for all recipients.
Manual editing before every campaign.Values are inserted automatically when sending.
Less efficient for bulk messaging.Ideal for personalised bulk campaigns.

Example Template

A template can contain one or more numbered variables.

Template ContentExample Result
Hello {{1}}, your order {{2}} has been shipped.Hello Suraj, your order ORD-10254 has been shipped.
Your appointment is scheduled for {{1}}.Your appointment is scheduled for 24 July 2026.

Types of Dynamic Content

WhatsApp templates in SPRL can contain different types of dynamic content. These are handled differently when the message is sent.

Dynamic ContentHow It WorksExample
Body VariablesText placeholders are replaced with values when the message is sent.{{1}} → Customer Name
Dynamic URLA URL button contains a dynamic value that is supplied when the message is sent.order/{{1}} → order/ORD12345
Dynamic MediaA media file is uploaded when the message is sent.Invoice PDF or personalised image
Important:
Dynamic media is not a numbered text variable. Images, videos, and documents are provided as media files when sending the message.

Using Variables in Campaigns

  1. Navigate to Dashboard → WhatsApp → Campaigns.
  2. Create a new campaign.
  3. Select an approved template.
  4. Provide values for each required body variable.
  5. Provide values for any dynamic URL buttons.
  6. Upload dynamic media if the template uses dynamic media.
  7. Review the message preview.
  8. Send or schedule the campaign.

Body Variables

Body variables are configured using numbered placeholders such as {{1}}, {{2}}, and {{3}}. Each required variable must receive a value before the campaign can be sent.

Dynamic URL Values

If the selected template contains a dynamic URL button, provide the value required by that button along with the body variables.

For example, if a template contains:

https://example.com/order/{{1}}

the value ORD12345 can be supplied when sending the message to produce a recipient-specific destination.

Dynamic Media

If the template uses dynamic media, upload the required image, video, or document when configuring the campaign.

Dynamic media is uploaded separately from text variables and does not occupy a numbered variable position.


Using Variables with the REST API

If you are sending messages through the REST API, include the variable values in your API request according to the selected template.

Body variable values must be provided in the same order as the variables defined in the template.

If the template contains a dynamic URL button, its dynamic value should be provided after the body variables in the same variables array.

Example:
If a template contains two body variables and one dynamic URL button, the variables array contains three values:

["John", "ORD12345", "ORD12345"]

Dynamic media is handled separately from the text variable array. When a template requires dynamic media, the required media file is uploaded with the API request.

Good to Know:
Body variables and dynamic URL values are sent as text values. Dynamic media is sent as a media file and is not included as a text variable.

Using Template Buttons

Templates can also include interactive buttons to improve customer engagement.

Button TypePurposeDynamic SupportLimit
Quick ReplyAllow recipients to respond with a predefined option.NoUp to 10 buttons per template.
Visit WebsiteOpen a specified website URL.Yes, dynamic URLMaximum 2 URL buttons.
Call PhoneAllow recipients to call a specified phone number.NoMaximum 1 phone button.
Copy CodeAllow recipients to copy a promotional or offer code.Template dependentMaximum 1 copy code button.

Dynamic URL Buttons

A Visit Website button can contain a dynamic URL value. This allows the same approved template to direct different recipients to different URLs.

Template URLDynamic ValueResult
https://example.com/order/{{1}}ORD12345https://example.com/order/ORD12345

Dynamic URL values are supplied after the body variables when using the REST API.

Tip:
Dynamic URL buttons are useful for order tracking, invoices, bookings, account pages, payment pages, and other recipient-specific destinations.

Dynamic Media

Templates can use dynamic media headers for images, videos, and documents.

Unlike body variables and dynamic URL values, dynamic media is not represented by {{1}}, {{2}}, or another numbered placeholder. The actual media file is supplied when the message is sent.

Media TypeExample
ImageProduct image or personalised graphic.
VideoProduct demonstration or promotional video.
DocumentInvoice, statement, report, ticket, or other document.

For example, a template can contain a dynamic document header and be used to send a different invoice PDF to each recipient when messages are created individually.

Important:
In a bulk campaign, SPRL supports one dynamic media file for the campaign. If every recipient requires a different media file, use the single-message REST API instead.

Variable Order

When a template contains both body variables and a dynamic URL button, SPRL processes the values in a defined order.

PositionValue
FirstBody variable values
After body variablesDynamic URL button values

For example, if a template contains two body variables and one dynamic URL button, the API request should provide:

{ "variables": [ "John", "ORD12345", "ORD12345" ]
}

The first two values are used for the body and the third value is used for the dynamic URL button.

Important:
Do not include dynamic media files inside the variables array. Media is uploaded separately.

Button Guidelines

RequirementDescription
Total ButtonsMaximum of 10 buttons per template.
Button LabelUp to 25 characters.
Website ButtonsSupport website links and dynamic URL values.
Phone ButtonsSupport click-to-call actions.
Quick RepliesAllow customers to respond with predefined choices.

Best Practices

  • Use variables only where personalised information is required.
  • Verify every variable value before sending a campaign.
  • Keep variable placement natural within the message.
  • Keep body variables in the same order as defined by the template.
  • Provide dynamic URL values after the body variables.
  • Do not include dynamic media files inside the variables array.
  • Ensure dynamic media matches the template's configured media type.
  • Use descriptive button labels that clearly explain the action.
  • Avoid creating unnecessary variables when static text is sufficient.
  • Preview templates before sending large campaigns.

Troubleshooting

My variable isn't showing the expected value

Verify that a value has been provided for every required body variable and that the values are supplied in the correct order.

I cannot send the template

Ensure the template has been approved and all required variables have valid values.

My dynamic URL is not working

Make sure the URL button was configured as a dynamic URL and that the required dynamic value is provided after the body variables.

My dynamic media is not being sent

Make sure the template is configured for dynamic media and that the uploaded file matches the template's media type.

I cannot add more buttons

Templates support a maximum of 10 buttons. Individual button types also have their own limits.

My button label is too long

Button labels can contain up to 25 characters. Shorten the text before saving the template.


Frequently Asked Questions

Can I use multiple variables in one template?

Yes. A template can include multiple body variables wherever personalised information is required.

Can every recipient receive different variable values?

Yes. Variable values can be supplied individually for each message when it is sent.

Can I use variables with the REST API?

Yes. Body variable values can be provided through API requests as well as WhatsApp campaigns.

Can a dynamic URL button have a different value for every recipient?

Yes. Dynamic URL values can be supplied separately for each message.

Is dynamic media a variable?

No. Dynamic media is uploaded as a file and is handled separately from text variables.

Can I use dynamic media in campaigns?

Yes. A dynamic image, video, or document can be uploaded when configuring a campaign. A single dynamic media file is used for the campaign.

Can I send different media files to different recipients?

Yes, when sending messages individually through the REST API. Bulk campaigns support one dynamic media file per campaign.

What button types are supported?

Templates support Quick Reply, Visit Website, Call Phone, and Copy Code buttons.


Learn More:
Continue with WhatsApp API Webhooks to learn how to receive message status updates and integrate WhatsApp events with your applications.
Tip: Reuse a single template with variables instead of creating multiple similar templates. This simplifies template management while allowing every recipient to receive personalised information.

Need more help?

Our support team is always happy to assist you.

×

We use cookies to improve your experience, analyse traffic, and personalise content. By clicking “Accept”, you consent to the use of cookies as described in our Cookie Policy .

Accept cookies Read our Cookie Policy