Is there an API or events that can be trapped within gmail so that I can initiate a workflow or even fire a python script.
I am trying to automate a job which will extract a csv attachment from an email that has arrived in gmail. It will then ETL the csv into BigQuery.
Any thoughts ?
Create an event from a Gmail messageOn your computer, go to Gmail. Open the message. Create event. Google Calendar creates an event, copying the Gmail message title and text.
On Android devicesOpen the Gmail app. Select your account and scroll to Notifications. Tap Inbox notifications and select your notification settings.
Recently did this integration:
Turn on watching for message events: https://developers.google.com/gmail/api/v1/reference/users/watch
When you get a new incoming messageId (messagesAdded
history type) you ask for its information (in full format): https://developers.google.com/gmail/api/v1/reference/users/messages/get
In metadata you look for a payload.parts[i]
where it has body.attachmentId
and get an attachment using its id: https://developers.google.com/gmail/api/v1/reference/users/messages/attachments/get
Im not sure within gmail itself,
but one thing you try is to write a python script utilising IMAP lib to read gmail messages and load it to bigquery using googleclient python. Set it using cron to run every x minutes to check the gmail account.
This should give you a starter code to read gmail messages:
https://gist.github.com/baali/2633554
If you want just new messages, just replace the search param 'ALL' with 'UNSEEN'.
More info: https://docs.python.org/2/library/imaplib.html
Example python to load it to BigQuery: https://developers.google.com/bigquery/loading-data-into-bigquery
I am still waiting for IFTTT https://ifttt.com/wtf to provide the API for users to create their own channel or custom action. i.e. Google BigQuery channel.
Hope that helps.
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