Gmail RPA and emails classification
How many times you missed an important email or had to filter the received emails in order to find the relevant ones? How useful it will be to automatically label emails by body content or attachment?
As an answer to the above problems, this short blog post will describe the process of building an email classifier with a low code strategy using Rinkt RPA and machine learning.
The emails will be classified based on the attachment into “invoice”, “receipt” and “other”. When an attachment is classified as “invoice” or “receipt”, the email will be labelled as “Financial”.
Image classification in machine learning
Machine learning (ML) is the study of computer algorithms that improve automatically through experience and by the use of data. In other words, the algorithms that learn from examples.
The chosen architecture for image classification is Inception-v3. Inception-v3 is a convolutional neural network architecture from the Inception family.
The following model is trained with 3 image groups: receipts, invoices and other. Each image group has around 400 images. As a result, some of the predicted labels may not be exact. For this reason, I set the score threshold to 0.50.
The Rinkt Google suite has many activities from Gmail to Drive, Docs, Scripts and others. The Google connection activity(Google connection context) establishes the connection between Rinkt and Google. As a result, all the google activities must be placed inside Google Api Scope sequence(see screenshot below).
The below sample uses 4 google activities:
- Google connection – sets up the connection
- Get emails – returns emails from GMail
- Update message labels – updates a Gmail email labels.
- Notify on message – invokes the children activities with the new messages received on the GMail box.
Therefore, to allow the above activities to connect to google, your google account must be configured accordingly.
To get the credentials for Google connection activity, please follow How to use google activities.
To listen for new emails, please follow How to enable Gmail Push Notifications.
The attached sample consists of 2 workflows:
- Connects to google, reads the first 10 emails, listen to any incoming emails and starts the classifier for the received emails.
- Classifies the received emails using the attachment and sets the Financial label on the emails classified as invoice or receipt when the score is over 0.5.
Get emails and listen for new emails
Just to reiterate, you must set the Client Id and Client Secret after configuring your google account using the above forum instructions.
Also, to be able to listen to any incoming emails, you need the Project Id, Subscription Id, Topic Name which can be obtained after following these instructions How to enable Gmail Push Notifications.