0

I am relatively new to GCP platform. I need to create a system wherein my team gets notifications whenever an email is received from there client.

I have to create a system which is publishing messages in pubsub topic filtered by email id.

example : I want to publish only those message/emails in which "To" and "From" fields has "example@gmail.com"

I have referred the online documentations but could not find the workaround. Is this possible using GCP? If not is there any other service via which I can achieve the same ?

We are using Gmail as the email client

Thanks

user2129794
  • 2,388
  • 8
  • 33
  • 51
  • Do you use the watch API? Are you aware that you are limited to 1 event/seconds per user ? If it's not a problem, try to print the message content (data but also attributes). You can filter on Attribute with Pubsub. The documentation don't mention attributes along with the notification, but.... maybe!! Have a try! – guillaume blaquiere Oct 01 '20 at 12:32
  • Pub/Sub and email are different technologies. What type of notification do you want to send? The simplest solution is to create a new email address that is a distribution list that forwards the email to each member of the group. Give that email address to your customer. Since you are using Gmail, this is a Gmail question and not a Google Cloud Platform question. There are similar questions: https://stackoverflow.com/questions/50032950/google-gmail-script-that-triggers-on-incoming-email – John Hanley Oct 01 '20 at 19:32

1 Answers1

1

What you can use, is Pub/Sub together with Cloud Functions, which enables to access Gmail programmatically. Your specific scenario could look as following:

  1. User sets up Gmail push notifications: every time a new message arrives at inbox, Gmail will send a notification to Cloud Pub/Sub.
  2. Cloud Pub/Sub delivers the new message notification to Google Cloud Functions.
  3. Upon arrival of the new message notification, a Cloud Functions instance connects to Gmail and retrieves the new message.
  4. Check who send the message, and perform specific actions.

Before setting up a Cloud Function to automatically read your emails, you must authorize its access to Gmail. Have a look for codelab scenario and see step by step how to perform specific actions and adjust the function for your needs. Additionally, you can take a look for official documentation here.

aga
  • 3,790
  • 3
  • 11
  • 18