Sending PostGrid Print & Mail with Klaviyo

When your business requires sending mail in an effective in scalable manner, PostGrid has your solution. In this guide, we will examine how to send Print & Mail using Klaviyo's Flows feature. In particular, this guide will demonstrate how to send a test letter using Klaviyo.

Overview

There are four stages in the process of sending mail with PostGrid

  • Creating a Flow
  • Creating a Trigger for the Flow
  • Adding an Action for the Flow
  • Filling in the Required Fields

Klaviyo Setup

Once you enter the Klaviyo dashboard, you must enable multifactor authentication. Under the profile tab, you will find instructions for Multifactor Authentication.

Creating a Flow

Using the left sidebar menu on the Klaviyo dashboard, click “Flows”.

Click the “Create flow” button located at the top of the page.

Next, click on the “Create From Scratch” button, also located at the top right corner of the page.

Lastly, give the flow a name and click ‘Create flow' to complete the process.

Creating a Trigger

A trigger is an event that prompts the Flow to proceed with whatever action it is setup with. You will want to add an appropriate trigger to prompt the start of your desired PostGrid Print & Mail action.

For this guide, we will be using the Newsletter trigger, which activates whenever someone subscribes to a newsletter.

Confirm the trigger, by hitting the “Done” button on the bottom left corner.

Adding an Action

An action is an event that the flow that runs after the trigger is set off

Drag the Webhook action onto the trigger in the center of the screen from the left-hand side panel.

Filling in the Required Fields:

Fill out the URL, Headers, and JSON Body fields of the webhook configuration to call the correct PostGrid Print & Mail API endpoint.

Filling in the URL

The URL chosen here will depend on the desired action to be performed. Since this guide is for sending letters, we will use the Letters endpoint from the PostGrid Print & Mail API, which is:

https://api.postgrid.com/print-mail/v1/letters

You can find the corresponding URL for other actions such as creating a contact, under our API Guide. To find the URL for the API endpoint simply navigate to the desired feature, and copy the URL found under the main header for that page.

However, due to certain limitations only API endpoints labelled, Post will be valid.

Filling in the Headers

The only headers required for this guide will be a key, value pair labeled x-api-key. This will be your API key provided PostGrid, which can be found under Settings in the PostGrid dashboard.

This is a unique key used by PostGrid to associate and authenticate a given request with your account.
Note: Please be sure to enter the ‘Test API Key' if you wish to test orders and the ‘Live API Key' only if you are sure about your order.

Filling in the JSON Body

JSON stands for JavaScript Object Notation. The JSON body data is what allows PostGrid's Print & Mail services to know the specific details of the mail you are sending, such as the recipient, the sender, and even the contents of the mail itself. For the purposes of sending a letter, we will need to provide the required fields as defined in the Body Params of the letter section of the API guide.

Note: Instead of providing HTML for the letter, you can simply provide a template_id for the desired template. Learn more about creating templates here.

Here is an example of the possible data you may want to fill in as the JSON body:

{ "to":{ "firstName":"{{ person.first_name|default:'' }}", "lastName":"{{ person.last_name|default:'' }}", "addressLine1":"{{ person|lookup:'$address1'|default:'' }}", "city":"{{ person.City|default:'' }}", "postalOrZip":"{{ person.Zipcode|default:'' }}", "countryCode":"US" }, "from":{ "firstName":"Jane", "lastName":"Doe", "addressLine1":"20 Bay Street", "city":"Toronto", "provinceOrState":"ON", "postalOrZip":"M5J 2N8", "countryCode":"CA" }, "template":"template_3etohcSS7EiBxKNNKMwZFF" }

Getting the Contact Information

Instead of specifying the specific contact details, another option is to simply provide a contact_id. As a result, the from field may instead look like.

"from":"contact_avPKdFJpXUxjFnnvccKzYR",

You may have also noticed that the “to” contact uses some unconventional notation. The “to” contact uses some Klaviyo profile properties. You can learn more from their guide here.

Getting the HTML and Template

If you've created your template using HTML, you can use that directly in the html field and replace the template field. If you've used our template editor to create your template, you can copy its HTML for use on Klaviyo via the Raw Data section:

Wrapping Up

To test the flow, simply click on the Preview button.

Then on the Send Test Request button.

Upon successful configuration of the flow, you will receive a notification and observe the creation of a letter on your dashboard containing the details you have specified in the JSON body.

After setting everything up correctly, you can set the flow to be live. Now you can access your desired PostGrid Print & Mail service through Klaviyo!

We Integrate with the
Platforms You Love

Connect PostGrid Print & Mail with ActiveCampaign to send letters, postcards and checks/cheques on demand and at scale

View All Integrations

Ready To Get Started?

Start transforming and automating your offline communications with PostGrid