I used Langchain/Langgraph to build a customer support email automation system for an AI agency. It consists of multiple AI agents working together to achieve the following steps:
- Check for new emails in the agency GMAIL inbox.
- Categorize email into 'customer_complaint', 'product_enquiry', 'customer_feedback', 'unrelated'.
- Synthesize queries to extract relevant information from RAG to answer customer.
- Write a draft email to respond to the client.
- Email verifier: Check the quality and correct formatting of the email, and ensure its relevancy.
This is the detailed flow of the system:
- Python 3.7+
- Groq api key
- Gmail API credentials
- Necessary Python libraries (listed in
requirements.txt
)
-
Clone the repository:
git clone https://github.com/kaymen99/langgraph-email-automation.git cd langgraph-email-automation
-
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the required packages:
pip install -r requirements.txt
-
Set up environment variables:
Create a
.env
file in the root directory of the project and add your GMAIL address, as we are using llama3-70b with Groq you must also get an API key to access it:MY_EMAIL=your_email@gmail.com GROQ_API_KEY=your_groq_api_key
-
Ensure Gmail API is enabled:
Follow this guide to enable Gmail API and obtain your credentials.
-
Start the workflow:
python main.py
The application will start checking for new emails, categorizing them, synthesizing queries, drafting responses, and verifying email quality.
You can customize the behavior of each agent by modifying the corresponding methods in the Nodes
class or the agents prompt prompts
located in the src
directory.
You can also add your own agency data into the data
folder, then you must create your own vector store by running (update first the data path):
python create_index.py
Contributions are welcome! Please open an issue or submit a pull request for any changes.
If you have any questions or suggestions, feel free to contact me at aymenMir1001@gmail.com
.