🤖 AI邮件分析器与自动回复器
一个由(某技术/平台)驱动的智能邮件分析与自动回复系统 DeepSeek V3.1 (免费), 模型上下文协议(MCP), Express.js,以及 n8n 用于工作流自动化。
✨ 特点
- 📊 表格/数据图表 基于人工智能的电子邮件分析
- 情感分析(正面/中性/负面) - 紧急程度检测(低/中/高) - 自动分类(支持/销售/咨询/投诉/反馈) - 关键点提取 - 行动项识别
- ✍️ 智能自动回复生成
- 情境感知的响应生成 - 多种语气选项(专业/友好/正式/体贴) - 适应邮件内容和情感
- 🔗(此符号在中文中无直接对应含义,通常表示链接或连接) 已准备好集成
- RESTful API端点 - n8n 支持 webhook - 用于代理集成的MCP工具定义
🚀 开始使用
先决条件
- Node.js >= 18.0.0
- npm 版本大于等于 9.0.0
- OpenRouter API密钥(用于DeepSeek V3.1)
安装
- 克隆仓库:
git clone https://github.com/NassimKhaldi/ai-email-analyzer.git
cd ai-email-analyzer- 安装依赖项:
npm install- 配置环境变量:
# Copy the example env file
cp .env.example .env
# Edit .env and add your API key- 启动服务器:
npm start服务器将在 http://localhost:3000
📡 API 接口端点
1. 分析电子邮件
分析电子邮件内容并提取见解。
POST /api/analyze-email
Content-Type: application/json
{
"subject": "Urgent: Product Issue",
"body": "I'm having trouble with your product...",
"sender": "customer@example.com",
"priority": "high"
}回答:
{
"success": true,
"analysis": {
"summary": "Customer reporting product issue",
"sentiment": "negative",
"urgency": "high",
"category": "support",
"keyPoints": ["product issue", "urgent attention needed"],
"actionRequired": "Technical support response required",
"suggestedTone": "empathetic",
"priority": "urgent"
}
}2. 生成自动回复
生成一封合适的电子邮件回复。
POST /api/generate-response
Content-Type: application/json
{
"subject": "Urgent: Product Issue",
"body": "I'm having trouble with your product...",
"sender": "customer@example.com",
"tone": "empathetic"
}回答:
{
"success": true,
"response": {
"subject": "Re: Urgent: Product Issue",
"greeting": "Dear Customer,",
"body": "Thank you for reaching out...",
"closing": "We appreciate your patience.",
"signature": "Best regards,\nSupport Team",
"fullResponse": "Complete formatted email..."
}
}3. 处理邮件(合并)
一次调用即可分析邮件并生成回复。
POST /api/process-email
Content-Type: application/json
{
"subject": "Question about pricing",
"body": "I'd like to know more about your pricing plans...",
"sender": "prospect@example.com"
}4. n8n Webhook(网络钩子)
用于n8n工作流集成的终端点。
POST /webhook/email
Content-Type: application/json
{
"subject": "...",
"body": "...",
"sender": "..."
}🔧 配置
环境变量
| 变量 | 描述 | 默认值 |
|---|---|---|
OPENROUTER_API_KEY 您的OpenRouter API密钥 | 必填 | |
PORT | 服务器端口 | 3000 |
NODE_ENV | 环境模式 | 开发环境 |
SITE_URL | 您的网站URL | http://localhost:3000 |
SITE_NAME | 您的网站名称 | AI 邮件分析器 |
N8N_WEBHOOK_URL | n8n Webhook URL | - |
🔌 n8n 集成
- 在n8n中创建一个新的工作流
- 添加一个指向以下地址的Webhook节点:
http://localhost:3000/webhook/email - 添加电子邮件触发器(IMAP、Gmail 等)
- 将电子邮件数据连接到Webhook
- 使用回复发送自动回复
示例n8n工作流:
[Email Trigger] → [HTTP Request to /webhook/email] → [Send Email with response]🛠️ MCP 集成
这些电子邮件工具与MCP兼容,并且可以与AI代理集成:
const { mcpTools } = require("./tools/emailTool");
// Use with MCP server
mcpServer.addTools([mcpTools.analyzeEmail, mcpTools.generateAutoResponse]);📝 开发
以开发模式运行,启用自动重载:
npm run dev项目结构
ai-email-analyzer/
├── server.js # Express server
├── tools/
│ └── emailTool.js # Email analysis & response generation
├── package.json
├── .env
└── README.md🤝 贡献
欢迎贡献!请随时提交拉取请求。
📄 许可证
这个项目遵循MIT许可证授权——详见 许可证 文件中详述。
📧 支持
对于问题和疑问,请在(相关平台/系统)上提交一个议题 。
______________________________________________________________________
由……制作 纳西姆·哈尔迪
