Email is reliable, global, and offers flexibility that can't be met by other communications channels.
In this workshop, you'll learn how to implement the Twilio SendGrid Email API, and you can expect some deliverability tips to help you start sending at scale. What kind of scale? In 2022, SendGrid sent more than 1.6 trillion messages — 50 billion of which were sent during the Black Friday and Cyber Monday week alone while maintaining a 99 percent delivery rate.
You'll also see how the SendGrid dynamic templating system makes it possible to personalize your messages for each customer, allowing you to build lasting connections with your audience.
The following documentation and resources will help you build upon what you learn in this workshop.
- How to send an email with Dynamic Transactional Templates
- The Design and Code Editor
- Using Handlebars
This outline provides abbreviated steps to help you follow along with the workshop. You can use this outline and the app in the 5K9 directory to replicate the workshop on your own.
- Introduction
- Overview
- Mail Send API
- Transactional vs marketing email
- Templates and personalization
- Deliverability
- App overview
- Twilio SendGrid App
- Gmail inbox
- Running app
- Goofy intro about 5K9
- Show form fill and receipt of confirmation email
- Overview
- Transactional vs marketing email
- Definitions and examples
- 80/20 ratio for transactional messages
- Building the app
- Build
signup-confirmation.js
- Helper library
- Install helpler library:
npm i @sendgrid/mail
- Import helper:
const sg = require("@sendgrid/mail");
- Install helpler library:
- API keys
- Set API key:
sg.setApiKey(process.env.SENDGRID_API_KEY);
- Create an API key in the SendGrid UI
- Restricted access key
- Set API key:
- Message object
- Create and explain
msg {}
object and fields.to: "[email protected]"
from: "[email protected]"
subject: "Welcome to 5K9"
html: "Hello, <strong>Runner</strong>!"
- Create and explain
- Send first request
- Deliverability
- Examine message warning
- SPF, DKIM
- Complete domain authentication
- Automated security benefits
- Send to a coworker
- Modify code and send a second request:
from: {email: "[email protected]"}
- Show warning is gone
- Drop full code sample
- Callout
- Set
to
address fromreqData
- Set
from
fromprocess.env
- Set
- Callout
- Templates
- Prepare code
- Stage
templateId
- Set
dynamicTemplateData
fromreqData
- Stage
- Build a template
- Add template
- Add version
- Show premade templates
- Design Editor benefits
- Quick overview
- Show modified template with dog
- Handlebars
- Walk handlebars examples in template
- Variable replacement
- Conditionals
- Walk handlebars examples in template
- Switch template version for Halloween
- Prepare code
- Helper library
- Build