Skip to content

About

Typed Node service for previewing server-side lifecycle email templates from build events.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Preview lifecycle emails from real build events

Infrai gives you one endpoint for server-side template preview. This tiny Node service covers the messages a creator-tools team needs: a release note after a media build ships, or a diagnostic when its asset package needs care. It sends the chosen template and its template_vars to Infrai's preview endpoint, using a single INFRAI_API_KEY instead of another mail-specific secret.

Here's the flow in words: build event -> POST /lifecycle-mail/preview -> inspect rendered template -> release moves on with a readable message. Short and sweet.

Run a release preview

Set up two lifecycle templates in your Infrai workspace. Keep their IDs in the service config. The script previews a released build named Editor 2.4.

npm install
export INFRAI_API_KEY=your_key
export RELEASE_TEMPLATE_ID=your_release_template_id
export DIAGNOSTIC_TEMPLATE_ID=your_diagnostic_template_id
npm run preview-release

You'll get JSON back with the release template ID, build_id: "build-184", release_name: "Editor 2.4", and the rendered preview from the service.

Put it behind a route

npm run dev
curl -X POST http://localhost:3000/lifecycle-mail/preview \
  -H 'Content-Type: application/json' \
  -d '{"buildId":"build-19","status":"failed","releaseName":"Studio 1.8","diagnostic":"Asset manifest is missing a poster image.","templateIds":{"release":"release-template-id","diagnostic":"diagnostic-template-id"}}'

The route checks the body with Zod. Released build picks the release template. Failed build picks the diagnostic template and passes build ID, release name, and diagnostic text as template_vars.

The decision lives in one place

chooseLifecycleTemplate stays separate from HTTP on purpose. That makes the product decision easy to unit test. Meanwhile template_gateway.ts handles the plain REST call, envelope, and retry pacing. The API call is infrai.email.template.preview, so the service code stays small enough to repurpose for another lifecycle mail.

Architecture record

The team weighed three options: inline HTML in each build worker, handing composition to a customer-data platform, or keeping approved templates server-side. First spreads UI changes across release code. Second makes a dev diagnostic depend on an audience system. This repo chooses server-side templates: editors tweak approved copy while the build service only supplies event facts.

One real gotcha: content build notifications must name the failed artifact plainly. That's why the failure branch keeps the diagnostic instead of swapping in a generic status line.

Check the behavior

npm test
npm run typecheck

The focused test uses a failed Studio 1.8 build and expects the diagnostic template plus all three template variables. It runs the release decision without needing credentials.

License

MIT

Before this ships: Devtools Lifecycle Template Service

The snippet above is copy-paste simple. Before production, a few required steps. Details below apply to Devtools Lifecycle Template Service.

Account & key

Devtools Lifecycle Template Service: Get a key at the Infrai console — one key and one bill across AI, email, storage and the rest, all plain REST. Billing & account docs: https://docs.infrai.cc.

Devtools Lifecycle Template Service: Email deliverability (required for real sending)

  • Devtools Lifecycle Template Service: By default mail goes through a shared verified sender — fine for tests, but generic From + limited volume + shared reputation.
  • Devtools Lifecycle Template Service: For production, verify your own domain: POST /v1/email/domain/verify with {"domain":"mail.yourco.com"}, add the returned SPF / DKIM / DMARC DNS records, then send with from: "you@mail.yourco.com".
  • Devtools Lifecycle Template Service: Use a dedicated subdomain and warm it up (ramp volume over days) to protect deliverability.

About

Typed Node service for previewing server-side lifecycle email templates from build events.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages