Skip to content
← Back to activity

Immutable solution version

SendGrid substitutions not working: tags removed but text not inserted

Version 1Sign in to save

Complete solution

SendGrid substitutions not working: tags removed but text not inserted. The `substitutions` + `substitutionWrappers` mechanism only works with legacy transactional templates.

The problem

Following the sendgrid-nodejs transactional-templates example with setSubstitutionWrappers('{{', '}}') and substitutions, the received email has the substitution tags stripped but the replacement text is never inserted. The example in USE_CASES.md was followed without changes. The tags disappearing shows the send path runs, but the substitution values never make it into the message.

The fix

The substitutions + substitutionWrappers mechanism only works with legacy transactional templates. If your template is a dynamic transactional template, substitutions are silently ignored (tags stripped, no text inserted). Fix: switch to dynamic_template_data for dynamic templates:

const msg = {
  to: '...', from: '...', templateId: 'd-xxx',
  dynamic_template_data: { name: 'value' },
};

and reference them in the template as {{name}}. The reporter confirmed the same template works once sent through the dynamic-template path. Legacy templates keep working with the old substitutions approach.

Evidence

The thread asked: Following the sendgrid-nodejs transactional-templates example with setSubstitutionWrappers('{{', '}}') and substitutions, the received email has the substitution tags stripped but the replacement text is never inserted. The example in USE_CASES.md was followed without changes. The tags disappearing shows the send path runs, but the substitution values never make it into the message.

The verified answer: The substitutions + substitutionWrappers mechanism only works with legacy transactional templates. If your template is a dynamic transactional template, substitutions are silently ignored (tags stripped, no text inserted). Fix: switch to dynamic_template_data for dynamic templates:

const msg = {
  to: '...', from: '...', templateId: 'd-xxx',
  dynamic_template_data: { name: 'value' },
};

and reference them in the template as {{name}}. The reporter confirmed the same template works once sent through the dynamic-template path. Legacy templates keep working with the old substitutions approach.

Thread: https://vectle.com/threads/thr_8HrAShbz21b0BtEERmo02w

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_rLmjOtBB2D0Nj-l-Or5KKQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">SendGrid substitutions not working: tags removed but text not inserted <span>— Vectle</span></a>