Using variables

Variables let you personalize messages with runtime data — names, plan tiers, URLs, dates, or anything else you can compute. You define placeholders like {{firstName}} in templates and layouts, then pass values from the Dashboard, SDK, or workflow runs.

Variable syntax

ChimeKit uses a simple moustache-style syntax:

  • {{myVariable}}
  • {{ myVariable }} (whitespace is ignored)

Variable keys can contain letters, numbers, _, -, and .. If a variable is missing, ChimeKit renders an empty string.

Where variables are used

Variables can be referenced anywhere ChimeKit interpolates strings, including:

  • Templates (in-app + email content)
  • Email layouts (for global header/footer text, brand copy, etc.)
  • Ad-hoc sends (manual channel content when sending without a template)
  • Workflow runs (context becomes variables for templates used in steps)

Passing variables from the Dashboard

The Dashboard is a great place to test variables quickly:

  1. Create a template with placeholders like Hello {{firstName}}.
  2. Send a test message and provide variable values in the send/test UI.
  3. Confirm the rendered result in your inbox (in-app) or email preview.

This helps you iterate on copy before wiring variables up in code.

Passing variables from code (Server SDK)

When you send a template, you’ll typically pass variables alongside the template reference:

@chimekit/node (template + variables)

import { ChimeKit } from "@chimekit/node";

const ck = new ChimeKit({ secretKey: process.env.CHIMEKIT_SECRET_KEY! });

await ck.messages.sendMessage("user_123", {
  content: {
    templateId: "tmpl_welcome",
    variables: {
      firstName: "Ava",
      "user.plan": "pro",
      dashboardUrl: "https://app.example.com",
    },
  },
});

Variables can also be used in manual in-app/email content (no template required):

@chimekit/node (manual in-app)

await ck.messages.sendMessage("user_123", {
  content: {
    variables: { firstName: "Ava" },
    in_app: {
      title: "Welcome, {{firstName}}",
      body: "Your account is ready.",
    },
  },
});

Variables in workflows

When you run a workflow, you can pass a context object. ChimeKit normalizes that context into variables that templates can reference during workflow steps.

@chimekit/node (workflow context)

await ck.workflow.run("welcome-sequence", {
  externalUserId: "user_123",
  context: {
    firstName: "Ava",
    dashboardUrl: "https://app.example.com",
  },
});

In your workflow’s message templates, you can reference {{firstName}} and {{dashboardUrl}}.

Tips for clean variable usage

  • Prefer a small, consistent set of keys (for example firstName, companyName, dashboardUrl).
  • Avoid putting secrets in variables (they may appear in logs, previews, or downstream systems).
  • Treat templates as contracts: document what variables a template expects and keep naming stable.

Was this page helpful?