SendGrid

Introduction

The SendGrid is a communication platform for transactional and marketing emails.

User Storie(s)

  • As a pipeline developer, I would like to query analytical data for marketing emails sent through Sendgrid, so that I can analyze and combine that data with other data sources.
  • As a pipeline developer, I would like to bulk send marketing emails to target customers through Sendgrid, so that I can effectively target them in marketing campaigns.

Plugin Type

  • Batch Source
  • Batch Sink 
  • Real-time Source
  • Real-time Sink
  • Action
  • Post-Run Action
  • Aggregate
  • Join
  • Spark Model
  • Spark Compute

Configurables

Batch source

Section

User Configuration Label

Label Description

Options

Default

Variable

User Widget

BasicAuthentication typeThe way, how user would like to be authenticated to the SendGrid acoount

Basic

Api Key

Basicauth-typeradio-group

API KeyThe SendGrid API Key taken from the SendGrid account of choiceShows if "Authentication type" is set to "api"
sendgrid-api-keysecurekey-text

UsernameLogin name for SendGridShows if "Authentication type" is set to "basic"
usernametextbox

PasswordPassword for the SendGrid accountShows if "Authentication type" is set to "basic"
passwordpassword

Data Source TypesList of data source groups
  • Marketing Campaigns Fields
  • Stats Fields
  • Suppressions Fields

dataSourceTypesmulti-select

Marketing Campaign ObjectsOne of the above sources picked from list

Marketing Campaigns Fields

  • Automation
  • Single Sends
  • Senders
  • Contacts
  • Segments



dataSourceMarketingmulti-select

Statistic ObjectsOne of the above sources picked from listStats
  • Global Stats
  • Category Stats
  • Advanced Stats

dataSourceStatsmulti-select

Suppression ObjectsOne of the above sources picked from listSuppressions
  • Bounces
  • Global Unsubscribes
  • Group Unsubscribes

dataSourceSuppressionsmulti-select

Data Source FieldsList of fields to be retrievedsee "Data sources description" section below
dataSourceFieldsmulti-select







OptionsStart Date(required by some SG API Endpoints)

The date in format YYYY-MM-DD, starting from which the data is requested.
Displayed depends on list of the selected data sourcesnot setstart-datetextbox

End Date(required by some SG API Endpoints)
The date in format YYYY-MM-DD, the end date for the requested data
Displayed depends on list of the selected data sourcesnot setend-datetextbox
Error HandlingOn Record ErrorHow to handle error in record processing
  • Skip error
  • Send to error port
  • Fail pipeline
Skip erroron-errorRadio Button (layout: block)

Batch sink

Section

User Configuration Label

Label Description

Options

Default

Variable

User Widget

BasicAuthentication type

The way, how user would like to be authenticated

to the SendGrid account

Possible options:

  • Basic
  • Api Key

Required field

Basicauth-typeradio-group

API KeyThe SendGrid API Key taken from the SendGrid accountShows if "Authentication type" is set to "api"
sendgrid-api-keysecurekey-text

UsernameLogin name for the SendGrid accountShows if "Authentication type" is set to "basic"
usernametextbox

PasswordPassword for the SendGrid accountShows if "Authentication type" is set to "basic"
passwordpassword

FromThe author of the messageRequired field
fromtextbox

Recipient address sourceRecipients addresses source selection

The recipient address possible sources:

  • Input Record (input)
  • Configuration (config)

Would be displayed depends on selection:

  • recipientColumnName
  • recipientConfigAddressList

Required field


recipientAddressSourceradio-group

Column name for

recipients addresses

Name of the column with coma-separated list of recipients

recipientColumnNametextbox

Recipient address listList of mail recipients

recipientConfigAddressListcsv

Email subjectEmail SubjectRequired field
mailSubjecttextbox

Email body column nameName of the column for the mail contentRequired field
bodyColumnNametextbox

Reply To

Email address to which the author of

the message suggests that replies be sent



replyTotextbox
OptionsCustom Mail FooterFooter feature setting switcher

Possible states:

  • On (true)
  • Off (false)
OfffooterEnabledtoggle

Footer HTML

The default footer which would be included

to every email



footerHtmltextarea

Sandbox Mode

Allows to send a test email to ensure that

your request body is valid and formatted correctly

Possible states:

  • On (true)
  • Off (false)
OffsandboxModetoggle

Click TrackingAllows to track whether a recipient clicked a link in a email

Possible states:

  • On (true)
  • Off (false)
OffclickTrackingtoggle

Open Tracking

Allows to track whether the email was opened

or not, by including a single pixel image in the body of

the content. When the pixel is loaded, SendGrid can log

that the email was opened

Possible states:

  • On (true)
  • Off (false)
OffopenTrackingtoggle

Subscription Tracking

Allows to insert a subscription management link at the

bottom of the text and html bodies of an email

Possible states:

  • On (true)
  • Off (false)
OffsubscriptionTrackingtoggle


Design Tips and references

SendGrid v3 API:

 - https://sendgrid.api-docs.io/v3.0/

 - https://sendgrid.com/docs/API_Reference/api_v3.html


SendGrid supports API v2 and v3 legacy and and SendGrid v3 API . As v2 and v3 legacy are outdated, we going to support and use the latest SendGrid v3 API.

User Expectations

  • User will retrieve API Keys (Restricted Access) from their SendGrid account for Event Notification, Marketing Campaigns, Suppressions and Tracking. 
  • User will enable Active Tracking in their account - Click, Open and Subscription tracking is enabled.
  • Uses SendGrid v3 REST API and Webhooks to sync your data. 
  • Retrieves 
    • Marketing Campaigns
      • Automation
      • Single Sends
      • Senders
      • Contacts
      • Segments
      • Schedule *
    • Stats
      • Global Stats
      • Category Stats
      • Advanced Stats
    • Suppressions
      • Bounces
      • Global Unsubscribes
      • Group Unsubscribes
      • Spam Reports **
      • Blocks **


    * is present as state in the list of Automation/Single Send, but could be parsed as separate list of both entities to represent the current schedule and be a dynamic entity
    ** currently no way to test or get info about those endpoints as for that, test account should have been reported for spam and have some blocks

Data source reference

Data sources description

Field nameType

Automation

idstring
namestring
statusstring
typestring
message_countnumber
created_atstring
updated_atstring
live_atstring

SingleSends

idstring
namestring
statusstring
created_atstring
updated_atstring
is_abtestboolean

Senders

idstring
nicknamestring
addressstring
address_2string
citystring
countrystring
statestring
zipnumber
lockedboolean
created_atstring
updated_atstring
from_emailstring
from_namestring
verified_statusstring
verified_reasonstring
reply_to_namestring
reply_to_emailstring

Contacts

idstring
first_namestring
last_namestring
list_idslist[string]
created_atstring
updated_atstring
emailstring

Segments

idstring
namestring
parent_list_idstring
created_atdatetime
updated_atdatetime
sample_updated_atdatetime
contacts_countnumber

GlobalStats

datestring
metrics_blocksnumber
metrics_bounce_dropsnumber
metrics_bouncesnumber
metrics_clicksnumber
metrics_deferrednumber
metrics_invalid_emailsnumber
metrics_opensnumber
metrics_processednumber
metrics_requestsnumber
metrics_spam_report_dropsnumber
metrics_spam_reportsnumber
metrics_unique_clicksnumber
metrics_unique_opensnumber
metrics_unsubscribe_dropsnumber
metrics_unsubscribesnumber

CategoryStats

namestring
typestring
datestring
metrics_blocksnumber
metrics_bounce_dropsnumber
metrics_bouncesnumber
metrics_clicksnumber
metrics_deferrednumber
metrics_deliverednumber
metrics_invalid_emailsnumber
metrics_opensnumber
metrics_processednumber
metrics_requestsnumber
metrics_spam_report_dropsnumber
metrics_spam_reportsnumber
metrics_unique_clicksnumber
metrics_unique_opensnumber
metrics_unsubscribe_dropsnumber
metrics_unsubscribesnumber

AdvancedStats

namestring
typestring
datestring
metrics_clicksnumber
metrics_opensnumber
metrics_unique_clicksnumber
metrics_unique_opensnumber

Bounces

createdstring
emailstring
reasonstring
statusstring

GlobalUnsubscribes

createdstring
emailstring

GroupUnsubscribes

idstring
namestring
descriptionstring
is_defaultboolean
last_email_send_atstring
unsubscribesnumber


Authorization

Plugin supporting Basic and API Key authorization, with using API Key by default when provided.


Rate limiting

SendGrid v3 API have an request rate limiting. The API requester have integrated way to retry over time to fetch wait for penalty time.

Approach

Create a module sendgrid plugin in sendgrid project with use of existing SendGrid library. Add SendGrid objects with their deserialization from API and transformation to structured records. 

UI Impact or Changes

SendGrid source and sink are separate entries with SendGrid logo in source and sink lists.

Test Case(s)

TODO

Sample Pipeline

TODO