Run SQL on Sendgrid engagement data for free
@dylburger
code:
data:privatelast updated:1 year ago
today
Build integrations remarkably fast!
You're viewing a public workflow template.
Sign up to customize, add steps, modify code and more.
Join 200,000+ developers using the Pipedream platform
steps.
trigger
Sendgrid
Deploy to generate unique URL
This workflow runs on Pipedream's servers and is triggered by HTTP / Webhook requests.
steps.
nodejs
auth
to use OAuth tokens and API keys in code via theauths object
code
Write any Node.jscodeand use anynpm package. You can alsoexport datafor use in later steps via return or this.key = 'value', pass input data to your code viaparams, and maintain state across invocations with$checkpoint.
async (event, steps) => {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
}
17
// Sendgrid events arrive as an array in the HTTP payload, for example:
// [
//   {"smtp-id":"<14c5d75ce93.dfd.64b469@ismtpd-555>","sg_message_id":"14c5d75ce93.dfd.64b469.filter0001.16648.5515E0B88.0","sg_event_id":"qTgCwJWfdwCw_PSs46Khrg==","event":"processed","category":"cat facts","email":"example@test.com","timestamp":1560406642},
//   {"smtp-id":"<14c5d75ce93.dfd.64b469@ismtpd-555>","sg_message_id":"14c5d75ce93.dfd.64b469.filter0001.16648.5515E0B88.0","sg_event_id":"qTgCwJWfdwCw_PSs46Khrg==","event":"processed","category":"cat facts","email":"example2@test.com","timestamp":1560406643}
// ]
//
// This workflow saves each event as a new record in the sendgrid_engagement_events table.
// You can run SQL on this data in the SQL tab at the top of this page. See
// https://docs.pipedream.com/destinations/sql/ for docs on the SQL service and running queries.
for (const row of event.body) {
  $send.sql({
    table: "sendgrid_engagement_events",
    payload: row, 
  })
}