/Gmail-API-and-Sentiment-Analysis

Send a request to Gmail API and shows subject of first five messages which might be congratulating the receiver.

Primary LanguagePython

Gmail-API-and-Sentiment-Analysis

Sends a request to Gmail API and shows subject of first five messages which might be congratulating the receiver.

Overview

This uses Gmail API call to return user's messages and then uses python's NLTK library for text parsing and returns the subject of the first five E-mails where the user is being congratulated.

Requirements Requirements to run the program are:-

Python 3.x
Pickle This comes installed with python package.
Gmail API call modules pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib

nltk

  1. pip install -U nltk
  2. Open python interpreter
  3. Type nltk.download()
  4. From the dialog box, select choices and download

Gmail API

  1. Go to https://console.developers.google.com/
  2. In the top left corner of the page, click on "Select a project".
  3. In the dialog box that opens up, click on "New project" in the top right corner.
  4. Type your project name, and click select.
  5. Click on "Enable API and service" on the page that opens up.
  6. Type in "Gmail API" in the search bar and click on the result.
  7. In the resulting page, click on Enable API.
  8. Click on "CREATE CREDENTIALS" on the next page.
  9. On the next page, choose "Gmail API", then select "Other UI(e.g. Windows, CLI tool) and then after selecting the button with the label "User data" click on "What credentials do I need" and grant permission.
  10. In the new tab that open up, type in application name and click save.
  11. Switch back to the main window and make click "Refresh".
  12. After that, click on "Create OAuth Client ID".
  13. Download the client ID that is generated.
  14. Rename the file to "credentials.json" and move it to the folder where the python script congratlations.py is located.

Further Developments

Gmail API is very extensive but at the same time, very difficult to understand from the documentation.
I'll try and make python scripts for the major API calls as tutorial. And maybe sprinkle a bit of text analysis and machine learning.

Feel free to improve the given code or the readme. Ideas are always welcome!
Thanks for reading!
TPT