Ryan-Neal Mes
Ryan-Neal Mes

Reputation: 6263

Send webhook upon sending or receipt of email

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?

Upvotes: 41

Views: 54801

Answers (4)

Sarthak Agarwal
Sarthak Agarwal

Reputation: 63

You can use Pub Sub API in your Google Cloud Project and attach a topic to your Gmail account. Create a topic and subscription and subscribe to that topic you created and add webhook in the subscription. After attaching topic to your Gmail account, You will be notified for every email sent or received.

Documentation: https://developers.google.com/gmail/api/guides/push

Reference Video: https://www.youtube.com/watch?v=cgxQPUyZAXk

Upvotes: 1

Alex Yatsenko
Alex Yatsenko

Reputation: 31

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.

Upvotes: 2

oarevalo
oarevalo

Reputation: 3466

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.

Upvotes: 5

Ryan-Neal Mes
Ryan-Neal Mes

Reputation: 6263

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.

Upvotes: 13

Related Questions