AI Agents Respond to Your Gmail🤖📧
10 Easy Steps — CrewAI
I made a team of AI agents in 10 easy steps — that CAN draft emails directly in my Gmail inbox.

I have been experimenting with different AI agent frameworks. One that is gaining popularity is CrewAI.
The awesome thing about many of these AI agent frameworks is — they include full code snippets to get you started.
Even if the code is way over your capabilities like in my case — you can still install them and try them out.
You can also get ChatGPT to completely customize them and build AI agents specifically for you — based on the example source code.
In this tutorial, I will show you how to install a full CrewAI example on your local computer (as long as you have an IDE like Visual Studio Code — free).
Here is a screenshot of the examples for CrewAI found on GitHub

I’m going to show you how easy it is to set up the first example.
What does the CrewAI-LangGraph Example do?
This example drafts an email response to any new email that comes into your Gmail inbox — that isn’t a newsletter or promotional in content.
It checks for emails every three minutes and drafts a response to the email.
Don’t worry — it doesn’t auto-respond to people in the default configuration.
How It Works
The CrewAI-LangGraph example has a default team of three AI agents.
The Senior Email Analyst starts by filtering out newsletters and promotional content.
Then the Email Action Specialist summarizes the email, highlights main points, and identifies the sender.
The Email Response Writer drafts a response based on the email thread, performs research if needed, and creates a draft in your Gmail inbox.
The system checks for new emails every 180 seconds. If a new email is detected, it goes through the workflow.
If you want to learn more AI tips and tricks to help grow your business and earn more money online:
👉 Sign up to our free 5-Day email course to grow 🚀 and earn💲👈
How Do I Set Up the CrewAI-LangGraph example?
1.Open your terminal and run:
Git clone https://github.com/joaomdmoura/crewAI-examples
2. Get to the correct directory in your IDE.
cd crewAI-examples
cd CrewAI-LangGraph
3. Open your IDE and go to .env.example
Open the .env file and enter your API keys:
- OPENAI_API_KEY
- TAVILY_API_KEY (tavily.com)
- MY_EMAIL (Your Gmail email address)
When you save the file, it should look like:
OPENAI_API_KEY=xxxxxx
TAVILY_API_KEY=xxxxxx
MY_EMAIL=xxxxxx
4: Create Credentials File
Create a credentials.json file. You will need your Gmail API key for this. Follow these steps:
- Go to the Google Cloud Console and login
Go to APIs and services>Enabled APIs and Services
Search (Gmail) and choose “Gmail API Activate”
After the Gmail API is activated, go to APIs and services>Credentials
- Create credentials (OAuth client ID for a desktop app). (give it a name but that can be anything)
- Download the credentials.json file and place it in your project folder. (keep it secure)
- Copy the contents into your credentials.json file in the project.
5: Main Files Overview
The main files are in the src folder:
- graph.py
- nodes.py
- state.py
These files handle the integration of LangGraph and CrewAI.
6: Define AI Agents
Inside the crew folder, you’ll find definitions for three AI agents.
You can change the roles to anything you want here.
You can edit the AI Agent roles to whatever you want — no coding
- Senior Email Analyst: Filters out unwanted emails.
- Email Action Specialist: Summarizes emails and identifies important details.
- Email Response Writer: Drafts email responses based on the conversation style.
7: Create Task Definitions
The tasks are divided into:
- Filter Email Task
- Action Required Task
- Draft Response Task
Each task is assigned to the respective agent.
8: Configure Tools
In the tools file, set up the Gmail toolkit. This tool drafts new emails and integrates with Langraph to check for new emails and draft responses.
9: Export your OpenAI API KEY
Run the following command in your terminal to export your OpenAI API key:
export OPENAI_API_KEY=your_api_key_here
10: Run the Main script:
python main.py
You will get a URL. Open it in your browser, select the email address to use, and authenticate. Once authenticated, the script will start checking for new emails.
That’s it. It will keep running as long as your Python script is.
I teach about how to use ChatGPT, AI, AI Agents, GPTs, and grow your online business.
Check out my 👉 AI Growth Guys Newsletter 👈
See my other channels below.
Check out our YouTube Channel
Our Facebook Page
Check out our website: AI Growth Guys

This story is published on Generative AI. Connect with us on LinkedIn and follow Zeniteq to stay in the loop with the latest AI stories.
Subscribe to our newsletter to stay updated with the latest news and updates on generative AI. Let’s shape the future of AI together!
