This project aims to enhance the efficiency of Gmail usage by utilizing LangGraph to create an intelligent agent that assists users with their daily inquiries related to Gmail. The agent can analyze user requirements, transform them into Gmail search syntax, and retrieve relevant emails based on specified criteria.
- The agent can determine if a user's request is related to Gmail and provide appropriate responses or suggestions.
- It can filter Gmail inboxes based on various parameters such as sender, recipient, subject, body content, attachments, and date ranges.
The project is structured around a workflow that integrates user input with a language model to provide responses. The main components include:
- LangGraph: For building agent workflow.
- OpenAI GPT-4: For generating responses based on user input.
The agent follows this basic workflow:
- Input Analysis: Analyzing user queries to determine intent
- Query Formation: Converting natural language into Gmail search syntax
- Email Retrieval: Fetching relevant emails from Gmail
- Response Generation: Providing useful information back to the user
- Python 3.10 or later
- OpenAI API key
- Google API key
- Gmail API credentials
- Python libraries (see requirements.txt)
-
Clone the repository:
git clone https://github.com/Haemon-Yang/Gmail-Assistant.git
-
Navigate to the project directory:
cd Gmail-Assistant -
Install the required dependencies:
pip install -r requirements.txt
-
Set up your environment variables by creating a
.envfile and adding the necessary keys.OPENAI_API_KEY = your_openai_api_key LANGCHAIN_API_KEY = your_langchain_api_key TAVILY_API_KEY = your_tavily_api_key
-
Set up Gmail API credentials:
Follow this guide to set up Gmail API credentials.
Important Note About Credentials:
- You need to generate a
credentials.jsonfile from the Google Cloud Console. - When you first run the application, it will use these credentials to generate a
token.jsonfile. - The
token.jsonfile contains OAuth 2.0 access tokens that expire periodically (typically after 1 hour). - Refresh tokens in
token.jsonmay also expire if:- The user revokes access
- The tokens haven't been used for an extended period
- You've reached Google's security limits
- If authentication fails, you may need to delete the
token.jsonfile and re-authenticate.
- You need to generate a
-
Run the application:
python main.py
To build and run the project using Docker, follow these steps:
-
Build Docker Image:
docker build -t gmail-assistant . -
Run Docker Container:
docker run -it --name container_name --env-file .env -p 5000:5000 gmail-assistant
Contributions are welcome! Please feel free to submit a pull request or open an issue for any suggestions or improvements.
This project is licensed under the MIT License.
