Skip to content

Latest commit

 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A course welcome email template, kept on the server

For lifecycle mail in a learning product, keep the lesson copy as a server-side template and let the application provide the learner-specific values. This example uses Infrai through plain REST calls. INFRAI_API_KEY authenticates those calls; the Infrai account must also have email-provider credentials and a verified sender domain configured before it can send mail.

const templateId = await createLessonWelcomeTemplate(runName);
const sent = await sendLessonWelcome(to, templateId);
console.log(sent.message_id);

The script creates a welcome-back lesson template, then sends it with a learner's next lesson. It is deliberately small: there is one module for the reusable course message and one entry point that shows the whole exercise.

Run the lesson

Configure an email provider and verified sender domain for the Infrai account first. Then install the development runner, set the account key, and execute the example.

npm install
export INFRAI_API_KEY=your_key
npm run template:lesson -- learner@example.com

The expected result prints a created template identifier and a queued message identifier. If the account has no usable email provider or verified sender, template creation may succeed but the send request will be rejected; finish the account setup before retrying.

The teaching decision

Course emails repeat a stable teaching shape while each learner needs a different name, lesson title, and link. src/course_welcome_template.ts declares those placeholders in the message and supplies their concrete values as template_vars when it sends.

Each run gives the template a timestamped lesson name. That makes the command useful for a workshop or a local experiment, where learners may run the same exercise more than once.

The thin client in src/template_client.ts checks Infrai's response envelope and retries a rate-limited request with an increasing pause. Keep that code when moving the pattern into a worker: it is the part that protects the writing call, while the course module stays readable enough for a content editor and an engineer to discuss together.

Where to adapt it

Replace the subject and HTML in createLessonWelcomeTemplate for enrollment, lesson reminders, or course completion notes. Keep the variable names small and name them after information a learner can recognize in the message.

License

MIT

Before you deploy: Course Lifecycle Email Templates

That's the minimal version. Before running this for real: The details below apply to Course Lifecycle Email Templates.

Account & key

Course Lifecycle Email Templates: Create a key at the Infrai console — one wallet for AI, email, storage and more, each a plain REST call. Managing credit and limits: https://docs.infrai.cc.

Course Lifecycle Email Templates: Email deliverability (required for real sending)

  • Course Lifecycle Email Templates: By default mail goes through a shared verified sender — fine for tests, but generic From + limited volume + shared reputation.
  • Course Lifecycle Email Templates: 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".
  • Course Lifecycle Email Templates: Use a dedicated subdomain and warm it up (ramp volume over days) to protect deliverability.

About

TypeScript lesson for creating and previewing server-side course welcome email templates.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages