构建基于GPT-4o的Telegram心理健康支持机器人
中级
这是一个Support Chatbot, AI Chatbot领域的自动化工作流,包含 15 个节点。主要使用 Set, Switch, Telegram, AimlApi, TelegramTrigger 等节点。 构建基于GPT-4o的Telegram心理健康支持机器人
前置要求
- •Telegram Bot Token
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"meta": {
"instanceId": "29cf227651b207fca8739269056bd8f95a432c5e246ffae4aaf9220581f6fe53",
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "0111b076-35d5-4bd1-b608-ec1bf479592b",
"name": "开始:在 Telegram 上接收消息",
"type": "n8n-nodes-base.telegramTrigger",
"position": [
1008,
752
],
"webhookId": "b04097ef-4484-4648-aee4-d3652537c8c3",
"parameters": {
"updates": [
"message"
],
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"id": "QcfQneMUvIojzFQz",
"name": "Telegram account"
}
},
"typeVersion": 1.1
},
{
"id": "c7f4bbc1-d12b-4f41-b430-aff228a795c9",
"name": "按输入类型路由",
"type": "n8n-nodes-base.switch",
"position": [
1456,
720
],
"parameters": {
"rules": {
"values": [
{
"outputKey": "Vent",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "71a70192-b1c2-44fc-9e0b-cad9cc5eaac4",
"operator": {
"type": "string",
"operation": "startsWith"
},
"leftValue": "={{ $('Start: Receive Message on Telegram').item.json.message.text }}",
"rightValue": "#vent"
}
]
},
"renameOutput": true
},
{
"outputKey": "Insight",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "1b5b1c7e-99e9-4e6d-a050-2d3c1c22c236",
"operator": {
"type": "string",
"operation": "startsWith"
},
"leftValue": "={{ $('Start: Receive Message on Telegram').item.json.message.text }}",
"rightValue": "#insight"
}
]
},
"renameOutput": true
},
{
"outputKey": "Cope",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "a9ad78e2-623b-4d1b-b0b8-bdaebf8bd71c",
"operator": {
"type": "string",
"operation": "startsWith"
},
"leftValue": "={{ $('Start: Receive Message on Telegram').item.json.message.text }}",
"rightValue": "#cope"
}
]
},
"renameOutput": true
},
{
"outputKey": "Any other",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "6f3a36ca-2348-4573-bbd7-4aa8088ec296",
"operator": {
"type": "string",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $('Start: Receive Message on Telegram').item.json.message.text }}",
"rightValue": ""
}
]
},
"renameOutput": true
}
]
},
"options": {}
},
"notesInFlow": false,
"typeVersion": 3.2
},
{
"id": "329aeb7a-9473-4893-b288-0a9db699d090",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
976,
-144
],
"parameters": {
"width": 540,
"height": 468,
"content": "## 🚀 快速入门指南"
},
"typeVersion": 1
},
{
"id": "3afdea7a-997f-4593-b5f3-f0ae4592dae4",
"name": "倾诉提示词",
"type": "n8n-nodes-base.set",
"position": [
1856,
464
],
"parameters": {
"mode": "raw",
"options": {},
"jsonOutput": "={\n \"prompt\": \"You are a compassionate therapist. The user is sharing their thoughts or feelings. Respond with empathetic validation, reflective listening, and gentle curiosity. Don’t offer solutions unless explicitly asked.\"\n}"
},
"typeVersion": 3.4
},
{
"id": "bdf9d3e9-6430-4a13-b7fc-2fe570720c1f",
"name": "洞察提示词",
"type": "n8n-nodes-base.set",
"position": [
1856,
656
],
"parameters": {
"mode": "raw",
"options": {},
"jsonOutput": "={\n \"prompt\": \"Act as an insightful psychologist. Analyze the user’s message and offer possible psychological insights or inner patterns behind their thoughts or behavior. Speak in clear, calm, and respectful language.\"\n}"
},
"typeVersion": 3.4
},
{
"id": "dd67ab30-9837-4e25-bee4-7011c49485ea",
"name": "应对提示词",
"type": "n8n-nodes-base.set",
"position": [
1856,
848
],
"parameters": {
"mode": "raw",
"options": {},
"jsonOutput": "={\n \"prompt\": \"The user is facing a tough emotional moment. Suggest 1–2 simple coping strategies (e.g. grounding, reframing, breathwork) based on their situation. Keep the tone warm, supportive, and practical.\"\n}"
},
"typeVersion": 3.4
},
{
"id": "da096c11-0b37-40e7-ba94-4ab65f3cb890",
"name": "所有其他消息的主提示词",
"type": "n8n-nodes-base.set",
"position": [
1856,
1040
],
"parameters": {
"mode": "raw",
"options": {},
"jsonOutput": "={\n \"prompt\": \"You're a compassionate AI mental health assistant trained in supportive conversation. The user wrote a message without a clear tag. Gently interpret what they might be asking or needing — whether it's support, insight, tools, or just someone to listen. Respond with warmth, emotional intelligence, and clarity. Avoid sounding like a robot or giving generic answers. Make it feel real and human.\"\n}"
},
"typeVersion": 3.4
},
{
"id": "98cf523a-aaf9-4e73-968c-15fe3fa4d0ef",
"name": "生成个性化回答",
"type": "n8n-nodes-aimlapi.aimlApi",
"position": [
2304,
752
],
"parameters": {
"model": "openai/gpt-4o",
"prompt": "={{ $json.prompt }}\n\nMessage:\n{{ $('Start: Receive Message on Telegram').item.json.message.text }}",
"options": {},
"requestOptions": {}
},
"credentials": {
"aimlApi": {
"id": "fzkUXwSArkMtWVYd",
"name": "AI/ML account"
}
},
"typeVersion": 1
},
{
"id": "292e839f-2843-486f-9a83-3624f0e8fdc0",
"name": "发送消息到 Telegram",
"type": "n8n-nodes-base.telegram",
"position": [
2528,
752
],
"webhookId": "fa689c4d-4c59-49c8-bbd6-0ab170d2f659",
"parameters": {
"text": "={{ $json.content }}",
"chatId": "={{ $('Start: Receive Message on Telegram').item.json.message.chat.id }}",
"additionalFields": {
"appendAttribution": false
}
},
"credentials": {
"telegramApi": {
"id": "QcfQneMUvIojzFQz",
"name": "Telegram account"
}
},
"typeVersion": 1.2
},
{
"id": "21b81566-ae81-483b-8430-71766e380426",
"name": "显示正在输入指示器",
"type": "n8n-nodes-base.telegram",
"position": [
1232,
752
],
"webhookId": "fa689c4d-4c59-49c8-bbd6-0ab170d2f659",
"parameters": {
"chatId": "={{ $('Start: Receive Message on Telegram').item.json.message.chat.id }}",
"operation": "sendChatAction"
},
"credentials": {
"telegramApi": {
"id": "QcfQneMUvIojzFQz",
"name": "Telegram account"
}
},
"typeVersion": 1.2
},
{
"id": "4d5093cf-bd4b-4435-b1bb-87d3befd4cf7",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
1392,
640
],
"parameters": {
"height": 288,
"content": "### 检查 message.text 中的 #vent、#insight、#cope 或回退处理"
},
"typeVersion": 1
},
{
"id": "9f5bc824-0d97-4009-83fe-781cfc4892a6",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
1552,
-80
],
"parameters": {
"width": 368,
"height": 320,
"content": "## 🔍 节点概览"
},
"typeVersion": 1
},
{
"id": "42a676f1-815f-4fc7-b537-4550f4ca8852",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
1792,
320
],
"parameters": {
"width": 224,
"height": 896,
"content": "## 从给定提示词中选择"
},
"typeVersion": 1
},
{
"id": "09df03c2-96dc-4872-bb52-213506ac8a72",
"name": "便签4",
"type": "n8n-nodes-base.stickyNote",
"position": [
2272,
656
],
"parameters": {
"width": 384,
"height": 272,
"content": "## 生成并发送答案到 Telegram"
},
"typeVersion": 1
},
{
"id": "e0c4e11c-ce6b-4c39-ad13-9108bfcaeda1",
"name": "便签5",
"type": "n8n-nodes-base.stickyNote",
"position": [
1952,
-80
],
"parameters": {
"width": 368,
"height": 320,
"content": "## **示例:**"
},
"typeVersion": 1
}
],
"pinData": {},
"connections": {
"Cope prompt": {
"main": [
[
{
"node": "Generate personalised answer",
"type": "main",
"index": 0
}
]
]
},
"Vent prompt": {
"main": [
[
{
"node": "Generate personalised answer",
"type": "main",
"index": 0
}
]
]
},
"Insight prompt": {
"main": [
[
{
"node": "Generate personalised answer",
"type": "main",
"index": 0
}
]
]
},
"Route by Input Type": {
"main": [
[
{
"node": "Vent prompt",
"type": "main",
"index": 0
}
],
[
{
"node": "Insight prompt",
"type": "main",
"index": 0
}
],
[
{
"node": "Cope prompt",
"type": "main",
"index": 0
}
],
[
{
"node": "Main prompt for all other messages",
"type": "main",
"index": 0
}
]
]
},
"Show Typing Indicator": {
"main": [
[
{
"node": "Route by Input Type",
"type": "main",
"index": 0
}
]
]
},
"Generate personalised answer": {
"main": [
[
{
"node": "Send message to Telegram",
"type": "main",
"index": 0
}
]
]
},
"Main prompt for all other messages": {
"main": [
[
{
"node": "Generate personalised answer",
"type": "main",
"index": 0
}
]
]
},
"Start: Receive Message on Telegram": {
"main": [
[
{
"node": "Show Typing Indicator",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级 - 客服机器人, AI 聊天机器人
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
使用Telegram、AIMLAPI和Google表格创建多模型AI聊天机器人
使用Telegram、AIMLAPI和Google表格创建多模型AI聊天机器人
If
Set
Code
+8
25 节点AI/ML API | D1m7asis
个人效率
使用Telegram机器人和GPT-4o创建个性化城市旅行行程
通过Telegram机器人和GPT-4o创建个性化城市旅行行程
Set
Switch
Telegram
+3
21 节点AI/ML API | D1m7asis
基于GPT-4o和Telegram的交互式俄语辅导机器人
基于GPT-4o和Telegram的交互式俄语辅导机器人
Set
Switch
Telegram
+3
16 节点AI/ML API | D1m7asis
内容创作
Telegram支持交接自动化
使用GPT4和邮件提醒自动化Telegram支持从AI到人工的交接
If
Set
Switch
+12
40 节点Meelioo
客服机器人
WhatsApp/Telegram WooCommerce订单支持
通过Telegram和Gmail使用Gemini和GPT自动化WooCommerce客户支持
Set
Gmail
Merge
+10
25 节点AppStoneLab Technologies LLP
客服机器人
Telegram命令中心
使用Telegram机器人命令中心自动化工作流执行
If
Set
Code
+5
23 节点Amir
客服机器人