Google Cloud Functions allows you to easily activate a function upon a trigger (eg Firebase data change, HTTP request...).
I am looking for a way to execute a function when a user sends (or typically replies) to a email address. For instance, my dashboard sends an email, I would like to catch the reply, parse the content and upload it to Firebase as a comment in my Dashboard.
I understand that Google recommends to use Sendgrid. I however don't understand: - How to setup the trigger upon a reply - How to read the content and set the reading
I only found how to send emails here
One option if you use GSuite is to use the Gmail watch mechanism to listen to new emails in your inbox. The message can then be posted to a PubSub topic which can trigger a Cloud Function to parse the email and perform your necessary next steps.
Here is a good use case that explains this mechanism
https://cloud.google.com/blog/products/application-development/adding-custom-intelligence-to-gmail-with-serverless-on-gcp
Google Cloud Functions does not provide a permanent listener on an endpoint. There is also no event source for SMTP, which is the protocols involved with email delivery. So you can't simple respond to emails as they come in with Cloud Functions at the moment.
What you can do is direct the traffic to an existing SMTP server, and then use Cloud Functions to read from there at an interval.
An alternative is to use the Sendgrid Inbound Email API, which can call a webhook for every message it receives. And your webhook would then be a HTTP triggered Cloud Function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With