Messages: email, SMS and notifications

Reach people where they are: a booking confirmation by email, a reminder by SMS, an alert inside the app. Each message is a template file with typed variables and a sample, so you can see it rendered before anything is sent. Workflows send them, once each, whether or not anyone has the app open.

The files

FileFront matterBody
messages/email/<name>.mdsubject, preheader, vars, sampleMarkdown, sent in the platform's email layout with the app's name and colour; a plain-text part is made for you. .html (yours) and .mjml work too
messages/sms/<name>.txtvars, sampleThe text
messages/notify/<name>.mdtitle, link, vars, sampleThe notification's text
prompts/<name>.mdsystem, max_tokens, model, vars, sampleAn AI prompt (see AI)

Code

---
subject: "Booking {{ref}} is confirmed"
preheader: Your team day is on.
vars:
  ref: string
  team_size: number
  link: url
sample:
  ref: BK-1234
  team_size: 12
  link: https://teamday.example.com/bookings
---
# You're booked

Booking **{{ref}}** for {{team_size}} {{plural team_size "person" "people"}} is confirmed.

[See your bookings]({{link}})

That is messages/email/booking-confirmed.md. A workflow sends it:

await step.send.email("booking-confirmed", {
  to: row.email,
  vars: { ref: row.ref, team_size: row.team_size, link: step.url("/bookings") },   // typed from vars:
});
await step.send.notify("bookings-waiting", { role: "ops", vars: { count } });       // or user: <user id>
await step.send.sms("class-reminder", { to: "+351912345678", vars: { title: s.title } });

Templates

  • Variables: {{var}}, {{a.b}}; values are escaped. {{{raw}}} only for a var typed html.
  • Blocks: {{#if x}}…{{else}}…{{/if}}, {{#unless}}, {{#each list}}{{this}}{{/each}}.
  • Helpers: date, money, upper, lower, truncate, plural, url.
  • Types for vars: string, number, boolean, date, url, email, html; string[] for a list, ? for optional, or an object of them.
  • Locales: booking-confirmed.hi-IN.md or .hi.md next to the default; step.send.email(…, { locale: "hi-IN" }) picks the exact one, then the language, then the default.

The check refuses an undeclared var, a raw var that isn't html, an unclosed block and an email without a subject; it warns about an unused var, a missing sample, an SMS over two segments, an email over 100 KB and http:// links.

Channels

ChannelSetup
In-app notificationNone. To one account (user) or everyone with a role
EmailNone: the platform sends it. to is one address or a list
SMSConnect Twilio: integrations { "action": "connect", "piece": "twilio", "credentials": { "account_sid", "auth_token", "from" } }
WhatsApp, Telegram, Slack and othersAn integration call in a step: there are no templates for them yet

Server actions send plain messages without a template: ctx.email({ to, subject, body }), ctx.sms({ to, body }).

Check it

message_previews { "project_id": "…" }     // every template rendered with its sample: subject, HTML, text, or the problem
workflows { "project_id": "…", "action": "dry_run", "id": "bookingconfirmed", "row": { … } }   // the send as an effect, not sent
tail { "project_id": "…", "kind": "emails", "since": "1h" }        // the outbox: subject, recipients, text, status

Emails from dev and from verify stay in the outbox and are never delivered, except to the project's owners and admins, unless the environment's secret APPBRICX_EMAIL_DELIVERY is live. So test freely with real addresses.

Gotchas

  • A failed send fails the step, which is retried; it shows in logs and can be replayed, never dropped silently.
  • One email per person from a schedule: loop over the rows in the workflow and call step.send.email for each, as the todo tutorial does. Each send in the loop is recorded on its own.
  • Phone numbers need a country code (+351…). The ctx.phone column type enforces it.
  • A user's own language isn't stored for you: keep it in a profile column and pass it as locale.

Related