Implementing Dyspatch

Dyspatch helps you take email templates out of your code base, allowing content creators to build complex email templates free from the deployment process. When it comes time to send an email, how does Dyspatch fit in? This guide outlines how to integrate Dyspatch into your system, and the steps to make Dyspatch a part of your email sending pipeline.

Template Life Cycle

The Dyspatch Process

Create, collaborate, and approve email content in Dyspatch. The Dyspatch API exposes approved compiled templates, with their snippets and styling already inlined. A Digital Messaging Service built in your system will store and build emails from the compiled templates taken from the Dyspatch API. How your Digital Messaging Service functions can vary depending on your organization's goals, but there are two main processes we'll outline below to get you started.

Digital Messaging Service

In order to effectively send emails with the most current content from your Dyspatch account, two functions will need to be performed by your Digital Messaging Service: Template Sync and Template Render. Template Sync to update your stored templates with any new content in Dyspatch, and Template Render to build a customer email from a template.

Template Sync

A sync of your templates on Dyspatch should be performed on a regular schedule (once per minute maximum) to update your datastore with any newly published content.

Template Sync Steps

1. Fetch List of Templates

Use the Dyspatch List Templates API get a list of your templates.

Get your list of templates

You'll receive a paginated response with all of your templates and their details. See List Templates to view details of the response.

2. Compare updatedAt Date-time

Compare the updatedAt fields to find newly published or updated templates.

Compare the updatedAt field

The first time you pull your templates and set up your datastore, you'll need to pull all your organization's templates. Once your templates have been cached, you can target the templates that are new or have been updated. This can be done by comparing the updatedAt fields on the templates in your datastore with the corresponding templates from the List Templates response.

3. Fetch Updated Content

Use Get template by ID for each template and Get localization object by ID to get each updated individual template localization.

Use get template and get localazation to get compiled templates

We recommend your datastore caches the full API response.

4. Update Your Datastore

Update your template datastore with the new and updated templates.

Fetch your list of templates

Your datastore should now be synced up with Dyspatch and the new and updated templates are available for use in the next step: Template Render.

Template Render

When it comes time to send an email, pull a compiled template from your datastore, insert the necessary data, and render the template to build an email.

Template Render Steps

1. Send Request Initiated

A send request is made by your system to your Digital Messaging Service.

A Send request is made

The send request from your system should request a template by ID and will need to provide a recipient address and any necessary customer data to customize the email for the recipient.

2. Fetch Template

Fetch the requested template using its template ID and, if needed, its locale from your template datastore.

Fetch a template from your datastore

3. Prepare Data

Prepare the template for render by inserting the recipient information.

Insert recipient information and localization

Recipient, sender, and localization data must be injected before rendering.

4. Render Using Templating Language

Render the HTML, text, and metadata for the final email. Visual templates can be fetched and rendered using any of the supported export languages.

Use your templating library to render HTML, text and metadata

5. Return for Sending

The template is customized and rendered for the end user and is ready to be returned for sending.

Return the ready to send email package

Ready to Send

With Template Sync and Template Render implemented your Digital Messaging Service will be able to serve the most up-to-date templates from your Dyspatch account and render customized emails ready to be passed on to your Email Service Provider for sending.

Didn't find what you're looking for?

Ask our support team, we're here to help!

Contact Support