Send webhook upon sending or receipt of email
Asked Answered
S

3

39

I have been looking around for how to create a webhook that is triggered when an email is sent or received in Gmail. For example someone sends an email, that email gets POSTed as a JSON object to one of my applications. I have found many middleman applications/services that do this (I found a tool that offers all the functionality I want, but it costs money), but I can't find any documentation on how to actually do this myself so I don't need to pay for it.

Is this possible?

Sudoriferous answered 29/5, 2014 at 7:56 Comment(3)
Do you need a pre-send hook or a post-send hook?Molnar
I solved it with zapier - this article covers it well: zapier.com/help/autoforwarding-email-gmailDispersal
@Dispersal I am using Gmail trigger and action is webhook in zapier. May I know if there is any way to read the response from the webhook in gmail-webhook zap , I need to trigger another action based on that response? (i.e gmail - webhook - gmail )Vituline
S
13

After some research the best solution I could find was to use the gmail API

To achieve the functionality that zapier offers you would have to have a service or something polling google and querying the status of a users in box. There are also a couple of ways to trigger calls to code, but I do not think this is what zapier does. Check the gmail API for more information.

Sudoriferous answered 26/8, 2014 at 7:16 Comment(4)
answer seems very outdated...Any good alternatives without Pooling...?Polish
developers.google.com/gmail/api/guides/pushGae
Can we get the content of the email using the webhook method of this gmail API?Premise
There is the option to subscribe to inbox, so you have exactly the zapier functionality freeRutherfordium
B
5

You can try using context.io They allow you to connect multiple gmail (and others) mailboxes and then create webhooks for different actions. They handle the polling for you and then whenever the condition is met, they call the URL that you provide.

Bedpan answered 13/5, 2015 at 18:3 Comment(4)
can context.io reply to a threaded email?Wednesday
@SazzadTusharKhan i don't think you can "send" replies via context.io; but you can configure a context.io webhook to "watch" any activity for a specific thread. For gmail, you get better results if you configure your webhook using the gmail's thread id and using the format: "gm-THREAD_ID"Bedpan
2019 update: context.io is officially shutting down due to changes in Google privacy policyUlster
context.io deprecation notice: blog.context.io/context-io-deprecation-notice-ce8b77e6e477Virtu
I
1

If using specifically Gmail doesn't matter to you you can use external services. For example, you can use ProxiedMail - generate a unique proxy email there and set up a webhook URL to your web page where you want to handle it.

It will redirect the letter to Gmail in the end but also will send you a callback to your endpoint. So, the difference here is only domain. Otherwise, you'll need to maintain a connection to Gmail by yourself.

Ileostomy answered 29/8, 2023 at 7:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.