An AI-powered email handling system built with LangGraph framework, specifically designed to automate customer support for QQ emails. The system automatically receives, categorizes, searches relevant documentation, and replies to customer emails.
- Automatic monitoring of new QQ emails
- AI-powered intelligent email classification (by type and urgency)
- Document search based on email content
- Automatic generation of professional and accurate responses
- Human review for complex emails
- Automatic bug reporting to Feishu
- Automated email replies
This project is built on the following technology stack:
- LangGraph - Building language agent workflows
- LangChain - Building AI applications
- Compatible chat model APIs with API keys - Various AI model services
- Python 3.11.x
- Python 3.11.x
- QQ email account and authorization code
- API key for compatible chat model (OpenAI, DeepSeek, etc.)
- Feishu app credentials (APP_ID, APP_SECRET, APP_TOKEN)
git clone https://github.com/ScarletMercy/IntelligentEmailHandlingCustomerService.git
cd IntelligentEmailHandlingCustomerServiceInstall directly from pyproject.toml:
pip install -e .Or build and install the package:
python -m build
pip install dist/*.whlBefore running the program, set the following environment variables:
export QQEMAIL=your_qq_email@qq.com # QQ email address
export EMAIL_PASSWORD=your_email_password # QQ email authorization code
export MODEL=your_model_name # Model name to use
export BASE_URL=your_api_base_url # API base URL
export API_KEY=your_api_key # API key
export APP_ID=your_feishu_app_id # Feishu app ID
export APP_SECRET=your_feishu_app_secret # Feishu app secret
export APP_TOKEN=your_feishu_app_token # Feishu app token
export RECEIVE_ID=your_receive_id # Feishu receive ID for messages
export TABLE_ID=your_table_id # Feishu table ID for bug trackingNotes:
- QQ email requires an authorization code instead of login password, which can be generated in QQ email settings
- MODEL, BASE_URL, API_KEY can be configured according to the model service used (e.g. OpenAI, DeepSeek, etc.)
- Feishu credentials are needed for bug tracking and messaging features
By default, runs in test mode:
python ThinkingInLangGraph.pyPass False parameter to run in production mode:
python ThinkingInLangGraph.py FalseAfter installation, you can use the following command:
ThinkingInLangGraphBuild the executable using the build script:
./build.shThe executable will be located in the dist/ directory.
- Email Monitoring: Continuously monitors new emails in QQ mailbox
- Email Classification: Uses AI to analyze email content and classify by intent and urgency
- Document Search: Searches relevant documentation based on classification results
- Response Drafting: Drafts responses based on search results and email content
- Special Handling:
- Complex or high-priority emails are sent for human review via Feishu
- Bug reports are automatically recorded in Feishu database
- Email Sending: Automatically sends reply emails to customers
The system classifies emails based on the following dimensions:
-
Intent(intent):
- question: General inquiries
- bug: Bug reports
- building: Deployment-related issues
- feature: Feature requests
- complex_request: Complex requests
-
Urgency(urgency):
- low: Low priority
- medium: Medium priority
- high: High priority
- critical: Critical
The project includes GitHub Actions configuration file for automatic building and testing.
The following secrets need to be configured in repository settings:
- MODEL: Model name to use
- BASE_URL: API base URL
- API_KEY: API key
- APP_ID: Feishu app ID
- APP_SECRET: Feishu app secret
- APP_TOKEN: Feishu app token
- RECEIVE_ID: Feishu receive ID for messages
- TABLE_ID: Feishu table ID for bug tracking
- QQEMAIL: QQ email address
- EMAIL_PASSWORD: QQ email authorization code
.
├── QQEmailListener.py # QQ email listener implementation
├── ThinkingInLangGraph.py # Core AI processing logic
├── build.sh # Build script for executable
├── pyproject.toml # Project configuration file
└── .github/workflows/
└── build-and-test.yml # GitHub Actions build and test configuration
- QQEmailListener class: Responsible for listening to QQ emails and fetching new emails
- ThinkingInLangGraph main workflow: LangGraph-based workflow that handles email classification, document search, response generation, etc.
- Feishu Integration: Integration with Feishu for bug tracking and messaging
- Various processing nodes:
- classify_intent: Email classification node
- search_documentation: Document search node
- bug_tracking: Bug tracking node
- to_human: Human escalation node
- draft_response: Response drafting node
- send_reply: Send reply node
You can extend the following features based on your requirements:
- Add more email classification types
- Integrate more powerful document search systems
- Add multi-language support
- Add email template management
- Enhance human review interface
- IMAP service must be enabled for QQ email
- Authorization code must be used instead of login password for QQ email
- Ensure stable network connection to access AI API
- It is recommended to add error handling and logging in production environments
This project is licensed under the MIT License - see the LICENSE file for details.