How to Use Template Variables in MessageHub

Template variables let you personalize messages in MessageHub by dynamically adding details like a customer’s name, email, or phone number. They can be used in conversations, canned responses, macros, and automations, helping you communicate efficiently while maintaining a personal touch. This article explains how to use template variables effectively across MessageHub.


Requirements:


What Are Template Variables?

Template variables are placeholders used to insert dynamic, personalized information into your messages in MessageHub. These variables automatically pull data from the customer's profile, such as their name, email address, or phone number, and replace the placeholder with the corresponding value when a message is sent.

For instance, instead of manually typing "Hi [Customer Name]" in every message, you can use {{ contact.name }}. When the message is delivered, the system automatically replaces {{ contact.name }} with "John Smith" or another contact’s name from your database.

Template variables can save time, reduce manual errors, and ensure your messages feel tailored to the recipient. They can be used in various features within MessageHub, including:

  • Conversations: Personalize responses directly in your live chat or email exchanges.

  • Canned Responses: Add a dynamic touch to pre-written replies by incorporating variables.

  • Macros: Automate personalized responses with template variables.

  • Automations: Use variables to streamline workflows and ensure custom communication.


How to Insert Template Variables

  1. Navigate to a text input field in MessageHub, such as a conversation, canned response editor, or automation editor. Begin typing your message in the text box.

  2. Type {{ (double curly braces) to open the list of available template variables. You’ll see suggestions like {{contact.name}}, {{agent.email}}, or {{conversation.id}}.

  3. Scroll through the list or type part of the variable name (e.g., “name”) to filter suggestions. Click on the variable you want to insert it into your message.

  4. Check your message to ensure the variables are pulling the correct data. For example:

    1. Draft: Hi {{contact.name}}, thank you for reaching out!

    2. Final Output: Hi Sarah, thank you for reaching out!

  5. Send the message or save it (if using a canned response). The variables will dynamically populate with the relevant data when sent.


List of Available Template Variables

MessageHub provides a variety of template variables to help you dynamically include key details in your messages. These variables are categorized to make it easy to find the information you need:

  • Conversation Details

    • {{conversation.id}}: The numeric version of the conversation ID.

  • Contact Details

    • {{contact.id}}: The numeric version of the contact ID.

    • {{contact.name}}: The contact's full name.

    • {{contact.first_name}}: The contact's first name.

    • {{contact.last_name}}: The contact's last name.

    • {{contact.phone_number}}: The contact's phone number.

  • Agent Details

    • {{agent.name}}: The agent's full name.

    • {{agent.first_name}}: The agent's first name.

    • {{agent.last_name}}: The agent's last name.

    • {{agent.phone_number}}: The agent's phone number.


Troubleshooting

What happens if a template variable is undefined?

If a template variable you’ve inserted is undefined, MessageHub will alert you with a warning message. This warning informs you that the variable doesn’t have any data assigned to it for the current context (e.g., if the contact’s phone number is missing).

You’ll be prompted with options:

  • Yes: Proceed to send the message with the placeholder variable intact.

  • No: Go back to edit your message or remove the undefined variable.

How can I add fallback text for undefined variables?

Fallback text acts as a backup for template variables that might be undefined or missing data. It ensures your messages remain clear and professional, even when certain information isn’t available for a contact or conversation. You can set fallback text using the following syntax:

{{ variable_name || 'fallback text' }}

For example:

  • If contact.first_name is undefined, you can use:
    {{ contact.first_name || 'there' }}

This will display “there” in place of the missing first name.