🎣 Automation scripts for fetching email messages from Gmail API.
Gmail Fisher allows you to query email messages in your Gmail inbox.
Some of these automation tasks are used for fetching email receipts from certain purchases made online,
scrapping email subjects, bodies and attachments; and mapping them to Expense objects, to serialize them
into .json
files.
Some existing adapters include fetching food expenses from UberEats or Bolt Food, or transportation expenses from Uber and Bolt.
Follows an example of the JSON output for such expenses:
[
{
"service": "Bolt Food",
"restaurant": "Hello Beijing",
"total_euros": 11.8,
"date": "2023-02-14",
"sender_email": "Bolt Food <[email protected]>"
},
{
"service": "Bolt Food",
"restaurant": "Poke House",
"total_euros": 14.29,
"date": "2023-02-11",
"sender_email": "Bolt Food <[email protected]>"
},
{
"service": "Bolt Food",
"restaurant": "DOTE",
"total_euros": 13.34,
"date": "2023-02-08",
"sender_email": "Bolt Food <[email protected]>"
}
]
Go to Google Cloud Platform console,
and under APIs and services
> Credentials
, create a new OAuth 2.0 Client ID
credential.
Under Actions
, click Download OAuth client
and then Download Json
.
Rename downloaded file to credentials.json
and place it under the auth
folder.
Filters available messages with Uber Eats and Bolt Food expenses.
Scraps data from those messages to populate a FoodExpense
iterable that will then be serialized to a Json file.
Example:
poetry run export_food_expenses --output-filepath='output/food_expenses.json'
Filters available messages with Bolt expenses.
Scraps data from those messages to populate a BoltTransportationExpense
iterable that will then be serialized to a Json file.
Example:
poetry run export_transport_expenses --output-filepath='output/transport_expenses.json'
Filters available messages with KEYWORDS
and from SENDER_EMAILS
and lists them.
Example:
poetry run list_messages --sender-email='[email protected]' --keywords='Delivery'
Filters available messages with KEYWORDS
and from SENDER_EMAILS
and lists them.
If filtered messages contain attachments, then those will be downloaded
to an output
directory and with a formatted name of PaySlip_YYYY-MM.pdf
.
Example:
poetry run save_attachments --sender-email='[email protected]|[email protected]' --keywords='payslip'