8
n8n 中文网amn8n.com

AI医疗症状检查器与健康助手

高级

这是一个Support Chatbot, AI Chatbot领域的自动化工作流,包含 17 个节点。主要使用 If, Set, Code, Merge, Webhook 等节点。 基于GPT-4-mini的医疗症状检查与健康助手

前置要求
  • HTTP Webhook 端点(n8n 会自动生成)
  • Airtable API Key
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "templateId": "ai-health-assistant-v1",
    "templateCreatedDate": "2024-01-15T00:00:00.000Z"
  },
  "name": "AI 医疗症状检查器与健康助手",
  "tags": [],
  "nodes": [
    {
      "id": "disclaimer-note",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -900,
        -500
      ],
      "parameters": {
        "width": 400,
        "height": 460,
        "content": "## 🏥 AI 健康助手"
      },
      "typeVersion": 1
    },
    {
      "id": "safety-protocols",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -500,
        -500
      ],
      "parameters": {
        "width": 320,
        "height": 400,
        "content": "## ⚠️ 安全协议"
      },
      "typeVersion": 1
    },
    {
      "id": "symptom-categories",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -150,
        -500
      ],
      "parameters": {
        "width": 280,
        "height": 420,
        "content": "## 📋 症状分类"
      },
      "typeVersion": 1
    },
    {
      "id": "configuration",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -900,
        -50
      ],
      "parameters": {
        "width": 320,
        "height": 380,
        "content": "## 🔧 配置设置"
      },
      "typeVersion": 1
    },
    {
      "id": "example-interactions",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        200,
        -500
      ],
      "parameters": {
        "width": 350,
        "height": 400,
        "content": "## 💬 示例对话"
      },
      "typeVersion": 1
    },
    {
      "id": "roadmap",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        600,
        -500
      ],
      "parameters": {
        "width": 300,
        "height": 420,
        "content": "## 📊 功能路线图"
      },
      "typeVersion": 1
    },
    {
      "id": "webhook-entry",
      "name": "健康查询 Webhook",
      "type": "n8n-nodes-base.webhook",
      "notes": "Receives health-related queries with strict privacy",
      "position": [
        -600,
        100
      ],
      "webhookId": "health-assistant",
      "parameters": {
        "path": "health-assistant",
        "options": {
          "responseHeaders": {
            "entries": [
              {
                "name": "Access-Control-Allow-Origin",
                "value": "*"
              },
              {
                "name": "X-Content-Type-Options",
                "value": "nosniff"
              }
            ]
          }
        },
        "httpMethod": "POST",
        "responseMode": "responseNode"
      },
      "typeVersion": 1.1
    },
    {
      "id": "safety-check",
      "name": "安全检查与分类",
      "type": "n8n-nodes-base.code",
      "notes": "Checks for emergencies and categorizes queries",
      "position": [
        -400,
        100
      ],
      "parameters": {
        "jsCode": "// Emergency keywords that trigger immediate response\nconst emergencyKeywords = [\n    'chest pain', 'heart attack', 'stroke', 'can\\'t breathe', 'breathing difficulty',\n    'unconscious', 'severe bleeding', 'suicide', 'overdose', 'poisoning',\n    'severe pain', 'allergic reaction', 'anaphylaxis', 'seizure'\n];\n\n// Extract user input\nconst userInput = $input.first().json.body?.query || $input.first().json.query || '';\nconst language = $input.first().json.body?.language || 'en';\nconst age = $input.first().json.body?.age || 'unknown';\nconst sessionId = $input.first().json.body?.sessionId || Math.random().toString(36).substring(7);\n\n// Check for emergency\nconst lowerInput = userInput.toLowerCase();\nconst isEmergency = emergencyKeywords.some(keyword => lowerInput.includes(keyword));\n\n// Categorize query type\nlet queryType = 'general';\nif (lowerInput.includes('symptom') || lowerInput.includes('pain') || lowerInput.includes('feel')) {\n    queryType = 'symptom';\n} else if (lowerInput.includes('medication') || lowerInput.includes('medicine') || lowerInput.includes('drug')) {\n    queryType = 'medication';\n} else if (lowerInput.includes('appointment') || lowerInput.includes('doctor') || lowerInput.includes('schedule')) {\n    queryType = 'appointment';\n} else if (lowerInput.includes('wellness') || lowerInput.includes('health tip') || lowerInput.includes('prevent')) {\n    queryType = 'wellness';\n}\n\n// Privacy notice\nconst privacyNotice = \"This conversation is not stored and is for informational purposes only.\";\n\n// Prepare output\nreturn {\n    userInput,\n    language,\n    age,\n    sessionId,\n    isEmergency,\n    queryType,\n    privacyNotice,\n    timestamp: new Date().toISOString(),\n    disclaimer: \"This is not medical advice. Consult healthcare professionals for medical concerns.\"\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "emergency-router",
      "name": "紧急情况路由",
      "type": "n8n-nodes-base.if",
      "position": [
        -200,
        100
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": false,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "c5528e99-6c2d-469e-aec6-ad5b07d5c8f1",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $json.isEmergency }}",
              "rightValue": true
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "emergency-response",
      "name": "紧急响应",
      "type": "n8n-nodes-base.set",
      "notes": "Immediate emergency response with contact numbers",
      "position": [
        0,
        0
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "emergency",
              "name": "response",
              "type": "string",
              "value": "=🚨 EMERGENCY DETECTED 🚨\n\n**CALL EMERGENCY SERVICES IMMEDIATELY:**\n\n🇺🇸 USA: 911\n🇬🇧 UK: 999\n🇪🇺 EU: 112\n🇦🇺 Australia: 000\n\n**Your message suggests a medical emergency.**\n\nWhile waiting for help:\n1. Stay calm\n2. Don't drive yourself\n3. Unlock doors for paramedics\n4. Have medications list ready\n5. Call someone to be with you\n\n**This is an automated response. Get immediate medical help!**"
            },
            {
              "id": "type",
              "name": "responseType",
              "type": "string",
              "value": "emergency"
            },
            {
              "id": "severity",
              "name": "severity",
              "type": "string",
              "value": "critical"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "health-ai",
      "name": "健康信息 AI",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "notes": "Provides general health information with strict guidelines",
      "position": [
        0,
        200
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4-mini"
        },
        "options": {
          "maxTokens": 1000,
          "temperature": 0.3
        },
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "=You are a helpful health information assistant. You provide general health information and wellness guidance while being very careful to:\n\n1. NEVER diagnose conditions\n2. NEVER prescribe medications\n3. NEVER replace professional medical advice\n4. ALWAYS recommend consulting healthcare providers for medical concerns\n5. ALWAYS emphasize this is general information only\n\nYour responses should be:\n- Informative but cautious\n- Empathetic and supportive\n- Clear about limitations\n- Focused on general wellness\n- Encouraging professional consultation\n\nFor symptom queries:\n- Provide general information about possible causes\n- Suggest when to see a doctor\n- Offer comfort measures if appropriate\n- Never minimize serious symptoms\n\nFor medication queries:\n- Only provide general information\n- Emphasize consulting pharmacists/doctors\n- Never suggest specific dosages\n- Mention common side effects only generally\n\nAlways end with a disclaimer about seeking professional medical advice."
            },
            {
              "role": "user",
              "content": "={{ $json.userInput }}\n\nContext:\n- Query Type: {{ $json.queryType }}\n- Language: {{ $json.language }}\n- Age Group: {{ $json.age }}\n\nPlease provide helpful general health information while being clear this is not medical advice."
            }
          ]
        }
      },
      "credentials": {
        "openAiApi": {
          "id": "{{YOUR_OPENAI_CREDENTIAL}}",
          "name": "OpenAI account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "format-health-response",
      "name": "格式化健康响应",
      "type": "n8n-nodes-base.set",
      "notes": "Adds disclaimers and resources to response",
      "position": [
        200,
        200
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "3d0292bc-0e07-4b55-9b7f-be0b417c2e05",
              "name": "response",
              "type": "string",
              "value": "={{ $json.message.content }}"
            },
            {
              "id": "e4e66a7a-1776-465b-865f-76666c5e3584",
              "name": "responseType",
              "type": "string",
              "value": "={{ $('Safety Check & Categorization').item.json.queryType }}"
            },
            {
              "id": "b2346867-40bb-4321-a3bd-59b948036dca",
              "name": "disclaimer",
              "type": "string",
              "value": "=⚕️ **Important Medical Disclaimer:**\nThis information is for educational purposes only and is not a substitute for professional medical advice, diagnosis, or treatment. Always seek the advice of your physician or other qualified health provider with any questions you may have regarding a medical condition."
            },
            {
              "id": "8f30e7de-3dcb-412f-bcd8-d8bbfff087fb",
              "name": "resources",
              "type": "string",
              "value": "=📞 **Health Resources:**\n• Find a doctor: https://doctor.webmd.com/\n• Symptom checker: https://www.mayoclinic.org/symptom-checker/\n• Mental health: https://www.samhsa.gov/find-help/national-helpline\n• Poison control: 1-800-222-1222 (US)"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "merge-responses",
      "name": "合并",
      "type": "n8n-nodes-base.merge",
      "position": [
        400,
        100
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combinationMode": "multiplex"
      },
      "typeVersion": 3
    },
    {
      "id": "compile-response",
      "name": "编译最终响应",
      "type": "n8n-nodes-base.code",
      "notes": "Creates structured response with all necessary information",
      "position": [
        600,
        100
      ],
      "parameters": {
        "jsCode": "// Compile final response\nconst input = $('Safety Check & Categorization').item.json;\nconst response = $input.first().json;\n\n// Build structured response\nconst output = {\n    success: true,\n    sessionId: input.sessionId,\n    timestamp: new Date().toISOString(),\n    query: {\n        original: input.userInput,\n        type: input.queryType,\n        isEmergency: input.isEmergency,\n        language: input.language\n    },\n    response: {\n        content: response.response,\n        type: response.responseType,\n        severity: response.severity || 'normal'\n    },\n    disclaimers: {\n        medical: response.disclaimer || input.disclaimer,\n        privacy: input.privacyNotice\n    },\n    resources: response.resources || null,\n    followUp: {\n        suggestedActions: getSuggestedActions(input.queryType, input.isEmergency),\n        nextSteps: getNextSteps(input.queryType)\n    }\n};\n\n// Helper functions\nfunction getSuggestedActions(queryType, isEmergency) {\n    if (isEmergency) return ['Call emergency services', 'Get immediate help'];\n    \n    const actions = {\n        symptom: ['Track symptoms', 'Schedule doctor visit', 'Rest and monitor'],\n        medication: ['Consult pharmacist', 'Read medication guide', 'Set reminders'],\n        appointment: ['Call your provider', 'Prepare questions', 'Gather medical history'],\n        wellness: ['Start healthy habits', 'Track progress', 'Set wellness goals'],\n        general: ['Consult healthcare provider', 'Learn more', 'Stay informed']\n    };\n    \n    return actions[queryType] || actions.general;\n}\n\nfunction getNextSteps(queryType) {\n    const steps = {\n        symptom: 'If symptoms persist or worsen, see a healthcare provider promptly.',\n        medication: 'Always follow prescription instructions and consult your pharmacist.',\n        appointment: 'Write down your concerns to discuss with your provider.',\n        wellness: 'Small daily changes can lead to significant health improvements.',\n        general: 'Your health is important - don\\'t hesitate to seek professional help.'\n    };\n    \n    return steps[queryType] || steps.general;\n}\n\nreturn output;"
      },
      "typeVersion": 2
    },
    {
      "id": "send-response",
      "name": "发送响应",
      "type": "n8n-nodes-base.respondToWebhook",
      "notes": "Returns health information with appropriate headers",
      "position": [
        800,
        100
      ],
      "parameters": {
        "options": {
          "responseCode": 200,
          "responseHeaders": {
            "entries": [
              {
                "name": "Content-Type",
                "value": "application/json"
              },
              {
                "name": "X-Health-Disclaimer",
                "value": "This is not medical advice"
              }
            ]
          }
        },
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify($json, null, 2) }}"
      },
      "typeVersion": 1.1
    },
    {
      "id": "integration-options",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        600,
        -50
      ],
      "parameters": {
        "width": 300,
        "height": 400,
        "content": "## 📱 集成选项"
      },
      "typeVersion": 1
    },
    {
      "id": "audit-log",
      "name": "审计日志(可选)",
      "type": "n8n-nodes-base.airtable",
      "notes": "Optional: Log queries for compliance (configure data retention)",
      "disabled": true,
      "position": [
        400,
        300
      ],
      "parameters": {
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "session_id",
              "fieldValue": "={{ $('Safety Check & Categorization').item.json.sessionId }}"
            },
            {
              "fieldId": "query_type",
              "fieldValue": "={{ $('Safety Check & Categorization').item.json.queryType }}"
            },
            {
              "fieldId": "is_emergency",
              "fieldValue": "={{ $('Safety Check & Categorization').item.json.isEmergency }}"
            },
            {
              "fieldId": "timestamp",
              "fieldValue": "={{ $('Safety Check & Categorization').item.json.timestamp }}"
            }
          ]
        },
        "resource": "database",
        "operation": "create",
        "databaseId": {
          "__rl": true,
          "mode": "list",
          "value": "health-assistant-logs"
        }
      },
      "typeVersion": 2
    }
  ],
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "connections": {
    "Merge": {
      "main": [
        [
          {
            "node": "Compile Final Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Emergency Router": {
      "main": [
        [
          {
            "node": "Emergency Response",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Health Information AI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Emergency Response": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Health Query Webhook": {
      "main": [
        [
          {
            "node": "Safety Check & Categorization",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Health Information AI": {
      "main": [
        [
          {
            "node": "Format Health Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Compile Final Response": {
      "main": [
        [
          {
            "node": "Send Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Health Response": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          },
          {
            "node": "Audit Log (Optional)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Safety Check & Categorization": {
      "main": [
        [
          {
            "node": "Emergency Router",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级 - 客服机器人, AI 聊天机器人

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量17
分类2
节点类型9
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

外部链接
在 n8n.io 查看

分享此工作流