SendGrid in Unqork

Overview

SendGrid is an external service that lets you send emails using API (application programming interface) calls. You'll set parameters like the email's subject, content, and sender all in your API request body. To do that in Unqork, you'll use a Plug-In component like you would with most other API calls. Whether you're building for yourself or a client, this article will help get your emails on their way.

What You’ll Learn

In this article, you’ll learn:

What is SendGrid?

SendGrid is a service that uses API calls to send customized emails. Based on your needs, you'll use API parameters to determine those customizations. So, if you want to send an email at any point in your application, you'll add a SendGrid API call.

Let's look at some examples of when you might send an email using SendGrid:

  • Your end-user submits an application and you want to send a confirmation.
  • Your end-user leaves an application incomplete and you want to send a reminder to finish it.
  • Your end-user submitted an application and, after some data-processing, you want to send them an update.
  • You want to send a reminder email on a scheduled cadence using a scheduled batch processing job.

NOTE  Because of SendGrid's versatility, it's one of the most commonly used services in Unqork. Although this article covers using SendGrid, there are similar services that serve the same purpose. Use the service that works best for you.

Configuration

Since SendGrid is an external service, you’ll have to do a little setup on both the SendGrid side and the Unqork side. In SendGrid, you’ll have to create unique sub-user accounts for each of your clients. In Unqork, you’ll have to set up the service under Services Administration. From there, you’ll configure the API call as you would any other in Unqork, using a Plug-In component in a remote execute. We’ll cover each of these in more detail later, but here’s a brief overview of each to get you started.

SendGrid Accounts

As you might expect, SendGrid is a paid service. You'll set up your account directly through SendGrid. So, SendGrid will authenticate each API call, and they’ll use API keys to do it. To get a unique API key, you’ll need to create 2 SendGrid sub-user accounts:

  • Quality Assurance (QA)
  • Production (Prod)

Having these subaccounts lets you test SendGrid configurations like email template structures without impacting those already in use. This is much like how each client has multiple Unqork environment stages (levels). There's a separate environment for building, testing, and production.

Unqork Services Administration

As with any service external to Unqork, you’ll need to set it up in your environment. You’ll do this under Services Administration. Here, you’ll enter the API key you received from SendGrid. This is how SendGrid recognizes and authenticates any API calls made from your environment. You’ll also enter the Service URL (https://api.sendrgid.comm/v3). For details on setting up an external service, read our Services Administration article.

Parameters for a SendGrid API Call

Let's talk about creating a SendGrid API call in your application. To do this, you’ll configure a Plug-In component to include certain parameters. While your emails may vary, each SendGrid API call needs the same base parameters in the request body. You'll find a comprehensive list of parameters in SendGrid's documentation (https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/index.html), but a few common parameters include:

Parameter Description

To

Recipients for the email. This can include just the email address of the recipient or both the name and email address.

From

Serves as the sender of the email. This can include just the email address you want to send from or both the name and email address.

Content

The body of the email. Here, you’ll specify your content as well as the type of content: plain text, html, and so on.

Template ID

When you select a template, the SendGrid template's formatting applies to your email. Also, each template you create has a unique Template ID. You’ll include that in your API call so SendGrid knows which template to use.

Once you’ve configured your API call, you’ll set up some sort of trigger. This could include a button-click, a new submission, or even the result of a Data Workflow.