Giter Club home page Giter Club logo

suin / google-cloud-functions-sendgrid-inbound-parse Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 0.0 3.74 MB

This package is a backend for SendGrid Inbound Parse. It runs on Google Cloud Platform Functions. It receives the form data from SendGrid and publishes an EmailData event to GCP Pub/Sub.

License: MIT License

TypeScript 96.14% Shell 3.86%
sendgrid sendgrid-inbound-webhook-parser google-cloud-platform gcp-cloud-functions serverless email-automation google-cloud-pubsub

google-cloud-functions-sendgrid-inbound-parse's Introduction

@suin/google-could-functions-sendgrid-inbound-parse

This package is a backend for SendGrid Inbound Parse. It runs on Google Cloud Platform Functions.

Architecture

  1. The GCP function publishEmailDataOnSendgridInboundParse is invoked by SendGrid Inbound Parse.
  2. It parses the form data that was posted by SendGrid.
  3. It transforms the form data into the EmailData object.
  4. It publishes the EmailData to GCP Pub/Sub topic allEmail.

Setting Up

Setting Up The Inbound Parse Webhook

Before using this package, please read the SendGrid's official document to set up the SendGrid Inbound Parse.

Deploying The Stacks To Your GCP

The deploy.sh a script that deploys this package to your Google Cloud Platform. The script performs these two operations:

  1. Create a new Pub/Sub topic to publish the email data which is posted by the SendGrid Inbound Parse Webhook.
  2. Deploy a new function. This function processes the form data which is posted by the SendGrid Inbound Parse Webhook, transforms the form data into an event payload, and publishes the event to the topic which was created by the operation above.

By default, the topic name is allEmail. If you would like to change it, please edit the deploy.sh.

To deploy these stacks, please run the following command:

./deploy.sh

Configuring The SendGrid Inbound Parse

Once the deployment success, go back to the SendGrid console and add the inbound parse webhook URL.

As this function expects raw email data, you have to enable the raw option in the SendGrid console:

Test Drive

After you have finished the setting up above, confirm the system works well.

At first, to make it possible to receive and read the messages that the function publishes, create a new subscription on the topic:

gcloud pubsub subscriptions create --topic allEmail testDrive
# If you have customized the topic name, please change the `allEmail` above.

At next, send a test email to the email address which the SendGrid Inbound Parse receives.

Then receive the message using the testDrive subscription:

gcloud pubsub subscriptions pull testDrive \
    --format="flattened(ackId,message.messageId,message.publishTime,message.attributes,message.data.decode(base64).encode(utf-8))" \
    --limit=10 \
    --auto-ack

If the system works without any problems, you will see some messages.

Finally, delete the testDrive subscription:

gcloud pubsub subscriptions delete testDrive

google-cloud-functions-sendgrid-inbound-parse's People

Contributors

semantic-release-bot avatar suin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.