User invitation emails — invite tokens, role context and expiry handled in the template

Team invite, organisation invite, role-specific access grant — each fires a domain event. else.events picks the right template, injects the invite token and delivers.

Why invitation emails are trickier than they appear

Invite tokens must be per-user and time-limited

A generic invite link in a template is a security risk. The token must be generated before the email is sent and included in the payload.

Role-specific invites need different copy

Inviting a viewer differs from inviting an admin. The email copy and permissions context should reflect the assigned role.

Expiry date must be visible in the email

Users need to know when the invite expires. This means the expiry timestamp must be in the event payload and rendered in the template.

Re-invite flow is a separate edge case

A resent invite may need different subject line copy ("Your invite was resent") and a new token without changing the email template structure.

Invite event, invite token, invite email — in one step

Include invite token in the event payload

Generate the token in your backend, include it in the event payload data. The template renders it as the CTA link — no generic links.

Rules select template by role

Admin invite and viewer invite can use different templates with role-appropriate copy. Rules route by role from the payload.

Expiry rendered from payload

Include expires_at in the payload. The template renders it directly — no hardcoded expiry text.

Re-invite uses the same event type

Fire the same team.invited event with a new token. Rules or a re-invite flag can select slightly different template copy.

// invitation event with token

Team invite event — token and role in the payload

{
  "type": "team.invited",
  "user": { "email": "newmember@example.com", "name": "Jordan" },
  "data": {
    "invited_by": "Alex",
    "role": "admin",
    "team_name": "Acme Engineering",
    "invite_url": "https://app.example.com/invite/accept?token=xyz789",
    "expires_at": "2026-06-01T23:59:00Z"
  }
}

else.events matches the rule for type = team.invited and role = admin, renders the admin invite template with the personalised invite_url and expires_at, then delivers through your provider.

Frequently asked questions

How do I include a personalised invite link in the email?
Generate the invite token and URL in your backend before firing the event. Include the full URL in the event payload data field. The template renders it as the CTA link.
Can I send different invite emails for different roles?
Yes. Include the role in the event payload. Rules match on it to select role-appropriate templates with the right permissions context and copy.
What happens if the invite expires — can I send a re-invite email?
Fire a new team.invited event with a fresh token. You can use a re_invite flag in the payload to trigger a slightly different template variant for re-invites.
Can invitation emails be sent in the invitee's language?
Include a locale in the event payload. Rules route to the correct language template for the invitation email.

Invitation emails with tokens, roles and expiry — from one event

Fire team.invited. else.events delivers the right invite to the right person.

  • Free during public beta
  • Role-based routing via rules
  • Invite tokens rendered from payload