{
  "name": "Spruce Patient Chat Agent - Phase 1 v3 (Fixed)",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "spruce-webhook",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "5f83a298-25dd-40b2-ae2b-d80643c45491",
      "name": "Spruce Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        -1520,
        2064
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={\"status\": \"ok\"}",
        "options": {}
      },
      "id": "bf276997-e19d-4d27-be3e-a16b6030df43",
      "name": "Respond OK",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        -1296,
        1920
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 1
          },
          "conditions": [
            {
              "id": "c1",
              "leftValue": "={{ $json.body.type }}",
              "rightValue": "conversationItem.created",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            },
            {
              "id": "c2",
              "leftValue": "={{ $json.body.data.object.direction }}",
              "rightValue": "inbound",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            },
            {
              "id": "c3",
              "leftValue": "={{ $json.body.data.object.isInternalNote }}",
              "rightValue": false,
              "operator": {
                "type": "boolean",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "72c86abf-95d2-496b-b59b-7cba1817e13e",
      "name": "Filter Inbound Messages",
      "type": "n8n-nodes-base.filter",
      "typeVersion": 2,
      "position": [
        -1296,
        2064
      ]
    },
    {
      "parameters": {
        "url": "=https://api.sprucehealth.com/v1/conversations/{{ $json.body.data.object.conversationId }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "<redacted-credential>="
            }
          ]
        },
        "options": {}
      },
      "id": "d5b2a81b-d240-4152-af9c-971ea2b02173",
      "name": "Fetch Conversation",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -1104,
        2064
      ]
    },
    {
      "parameters": {
        "url": "=https://api.sprucehealth.com/v1/conversations/{{ $('Filter Inbound Messages').item.json.body.data.object.conversationId }}/items?pageSize=3",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "<redacted-credential>="
            }
          ]
        },
        "options": {}
      },
      "id": "cb9fe212-09e7-4493-8726-4646220c4568",
      "name": "Fetch Conversation Items",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -912,
        2064
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 1
          },
          "conditions": [
            {
              "id": "block1",
              "leftValue": "={{ JSON.stringify($('Fetch Conversation').item.json.tags || []) }}",
              "rightValue": "block_chatbot",
              "operator": {
                "type": "string",
                "operation": "notContains"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "99420da1-9fab-4993-9717-5eec2f96092e",
      "name": "Block Chatbot Check",
      "type": "n8n-nodes-base.filter",
      "typeVersion": 2,
      "position": [
        -736,
        2064
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 1
          },
          "conditions": [
            {
              "id": "tag1",
              "leftValue": "={{ JSON.stringify($('Fetch Conversation').item.json.tags || []) }}",
              "rightValue": "NewPatient",
              "operator": {
                "type": "string",
                "operation": "contains"
              }
            },
            {
              "id": "tag2",
              "leftValue": "={{ JSON.stringify($('Fetch Conversation').item.json.tags || []) }}",
              "rightValue": "prospective",
              "operator": {
                "type": "string",
                "operation": "contains"
              }
            }
          ],
          "combinator": "or"
        },
        "options": {}
      },
      "id": "e838a632-8cf2-4823-a3d1-9c1f1b6a91e8",
      "name": "Prospective or Existing?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        -560,
        2064
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://openrouter.ai/api/v1/chat/completions",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "<redacted-credential>"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "HTTP-Referer",
              "value": "https://contourhealth.app.n8n.cloud"
            },
            {
              "name": "X-Title",
              "value": "JP Patient Chat Agent"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"model\": \"anthropic/claude-sonnet-4-5\",\n  \"max_tokens\": 1024,\n  \"messages\": [\n    {\n      \"role\": \"system\",\n      \"content\": \"You are the virtual front desk assistant for Journey Pediatrics. You do NOT have a name. Never introduce yourself with any name or label.\\n\\nABSOLUTE RULES:\\n1. NEVER give yourself a name or label of any kind.\\n2. NEVER reference any staff member by name.\\n3. NEVER give medical advice, diagnoses, treatment recommendations, or medication guidance.\\n4. NEVER interpret symptoms or lab results.\\n5. NEVER guess or make up information. If you don't have explicit information below, say: \\\"I'd love to help with that! Let me connect you with our team \u2014 you can book a quick call here: https://calendly.com/d/cvmt-sbx-rwh/journey-pediatrics-discovery-call\\\"\\n6. For ANY clinical question, respond warmly: \\\"That's a great question for our care team! I'll make sure they see your message and get back to you soon.\\\"\\n7. Never pretend to be a doctor, nurse, or clinical staff.\\n8. Keep responses concise (2-3 sentences max), warm, and professional.\\n9. If patient seems upset or mentions emergency: \\\"I want to make sure you get the right help. If this is an emergency, please call 911 or go to your nearest emergency room. Otherwise, let me flag this for our care team right away.\\\"\\n\\nIMPORTANT: Only respond to the LAST user message. Ignore any older context that seems unrelated to the current question.\\n\\nRESPONSE FORMAT \u2014 you must ALWAYS respond with valid JSON in this exact format, no markdown fences:\\n{\\\"reply\\\": \\\"your patient-facing message here\\\", \\\"escalate\\\": false}\\nSet escalate to true if: the patient mentions an urgent concern, symptoms, medication, clinical questions, or anything requiring care team attention. Set escalate to false for general admin questions only.\\n\\nPRACTICE FACTS (only state these \u2014 nothing else):\\n- Name: Journey Pediatrics\\n- Model: Cash-pay and membership-based practice. We do NOT accept insurance.\\n- Services: General functional health, PANS/PANDAS, ADHD, and support for kids on the spectrum.\\n- Ages: 1 month to 21 years old.\\n- Address: 1054 Johnnie Dodds Blvd, Mt Pleasant, SC 29464\\n- Phone: (843) 604-1957\\n- Website: www.myjourneypeds.com\\n- Booking: https://calendly.com/d/cvmt-sbx-rwh/journey-pediatrics-discovery-call\\n- Office hours: No set office hours. Direct to booking link or website.\\n\\nFOR PRICING, INSURANCE, OR ANYTHING NOT LISTED ABOVE:\\nDirect patients to the website (www.myjourneypeds.com) or book a call (https://calendly.com/d/cvmt-sbx-rwh/journey-pediatrics-discovery-call). NEVER guess.\"\n    },\n    {{ (function() {\n      const items = $('Fetch Conversation Items').item.json.conversationItems || [];\n      const now = Date.now();\n      const cutoff = now - (24 * 60 * 60 * 1000);\n      const history = items\n        .filter(m => !m.isInternalNote && m.text && m.text.trim() !== '' && (new Date(m.createdAt || m.timestamp || m.created || 0)).getTime() > cutoff)\n        .slice(0, 3)\n        .map(m => ({\n          role: m.direction === 'inbound' ? 'user' : 'assistant',\n          content: m.text.trim()\n        }));\n      const deduped = [];\n      let lastRole = 'system';\n      for (const m of history) {\n        if (m.role !== lastRole) {\n          deduped.push(m);\n          lastRole = m.role;\n        }\n      }\n      const fallbackText = $('Filter Inbound Messages').item.json.body.data.object.text || '';\n      if (deduped.length === 0 || deduped[deduped.length - 1].role !== 'user') {\n        deduped.push({ role: 'user', content: fallbackText });\n      }\n      return JSON.stringify(deduped).slice(1, -1);\n    })() }}\n  ]\n}",
        "options": {}
      },
      "id": "f912fb39-bce8-4341-8e06-6776a70ef848",
      "name": "Claude AI Response (Prospective)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -384,
        1968
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://openrouter.ai/api/v1/chat/completions",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "<redacted-credential>"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "HTTP-Referer",
              "value": "https://contourhealth.app.n8n.cloud"
            },
            {
              "name": "X-Title",
              "value": "JP Patient Chat Agent"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"model\": \"anthropic/claude-sonnet-4-5\",\n  \"max_tokens\": 1024,\n  \"messages\": [\n    {\n      \"role\": \"system\",\n      \"content\": \"You are the virtual front desk assistant for Journey Pediatrics. You do NOT have a name.\\n\\nABSOLUTE RULES:\\n1. NEVER give yourself a name or label.\\n2. NEVER reference any staff member by name.\\n3. NEVER give medical advice, diagnoses, treatment recommendations, or medication guidance.\\n4. NEVER interpret symptoms or lab results.\\n5. NEVER guess or make up information.\\n6. Never pretend to be a doctor, nurse, or clinical staff.\\n7. Keep responses concise (2-3 sentences max), warm, and personal \u2014 this patient already knows us.\\n8. If the patient seems upset or mentions an emergency: \\\"I want to make sure you get the right help. If this is an emergency, please call 911 or go to your nearest emergency room. Otherwise, I'm flagging this for our care team right now.\\\"\\n9. NEVER include any discovery call or Calendly links. This patient is already with us.\\n10. For appointment cancellations or changes, respond: \\\"For appointment cancellations or changes, please call us directly at (843) 604-1957. Our team can help you right away!\\\"\\n\\nIMPORTANT: Only respond to the LAST user message. Ignore any older context that seems unrelated to the current question.\\n\\nYOUR GOAL:\\nYou are helping an existing Journey Pediatrics patient. Your only job is to understand what they need. Ask one clear, warm follow-up question if their message is vague. Categories to identify:\\n- Refill or medication question\\n- Appointment request, scheduling, cancellation, or change\\n- Question for the care team\\n- Test results or lab follow-up\\n- Urgent concern\\n\\nOnce you understand what they need, acknowledge it warmly and let them know the care team will follow up. Do NOT try to resolve clinical matters yourself.\\n\\nFor appointment cancellations, changes, or rescheduling: Direct them to call (843) 604-1957 so the team can help immediately.\\n\\nRESPONSE FORMAT \u2014 you must ALWAYS respond with valid JSON in this exact format, no markdown fences:\\n{\\\"reply\\\": \\\"your patient-facing message here\\\", \\\"escalate\\\": true}\\nAlways set escalate to true for existing patients \u2014 every message needs care team visibility.\\n\\nEXAMPLE REPLIES:\\n- \\\"Got it! I'll make sure the team sees this. Are you looking to schedule a follow-up, or is this more of a quick question?\\\"\\n- \\\"Thanks for reaching out! Just so I can flag this correctly \u2014 is this about a refill, or something else going on?\\\"\\n- \\\"I'll pass this along to the care team right away. Is there anything specific you'd like them to know before they reach out?\\\"\\n- \\\"For appointment cancellations or changes, please call us directly at (843) 604-1957. Our team can help you right away!\\\"\"\n    },\n    {{ (function() {\n      const items = $('Fetch Conversation Items').item.json.conversationItems || [];\n      const now = Date.now();\n      const cutoff = now - (24 * 60 * 60 * 1000);\n      const history = items\n        .filter(m => !m.isInternalNote && m.text && m.text.trim() !== '' && (new Date(m.createdAt || m.timestamp || m.created || 0)).getTime() > cutoff)\n        .slice(0, 3)\n        .map(m => ({\n          role: m.direction === 'inbound' ? 'user' : 'assistant',\n          content: m.text.trim()\n        }));\n      const deduped = [];\n      let lastRole = 'system';\n      for (const m of history) {\n        if (m.role !== lastRole) {\n          deduped.push(m);\n          lastRole = m.role;\n        }\n      }\n      const fallbackText = $('Filter Inbound Messages').item.json.body.data.object.text || '';\n      if (deduped.length === 0 || deduped[deduped.length - 1].role !== 'user') {\n        deduped.push({ role: 'user', content: fallbackText });\n      }\n      return JSON.stringify(deduped).slice(1, -1);\n    })() }}\n  ]\n}",
        "options": {}
      },
      "id": "18f25619-f569-487d-b3f2-4ad641002b79",
      "name": "Claude AI Response (Existing)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -384,
        2208
      ]
    },
    {
      "parameters": {
        "url": "=https://api.sprucehealth.com/v1/conversations/{{ $('Filter Inbound Messages').item.json.body.data.object.conversationId }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "<redacted-credential>="
            }
          ]
        },
        "options": {}
      },
      "id": "a1b2c3d4-1111-4aaa-bbbb-000000000001",
      "name": "Re-fetch Conversation (Prospective)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -176,
        1968
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 1
          },
          "conditions": [
            {
              "id": "reblock1",
              "leftValue": "={{ JSON.stringify($json.tags || []) }}",
              "rightValue": "block_chatbot",
              "operator": {
                "type": "string",
                "operation": "notContains"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "a1b2c3d4-2222-4aaa-bbbb-000000000002",
      "name": "Block Re-check (Prospective)",
      "type": "n8n-nodes-base.filter",
      "typeVersion": 2,
      "position": [
        0,
        1968
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 1
          },
          "conditions": [
            {
              "id": "e1",
              "leftValue": "={{ (function() { const raw = $('Claude AI Response (Prospective)').item.json.choices[0].message.content; const clean = raw.replace(/^```json\\s*/i, '').replace(/^```\\s*/i, '').replace(/```\\s*$/i, '').trim(); return JSON.parse(clean).escalate; })() }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "equals"
              }
            }
          ],
          "combinator": "or"
        },
        "options": {}
      },
      "id": "359a1615-ad0a-421b-b696-009937ecf6e0",
      "name": "Needs Escalation? (Prospective)",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        176,
        1968
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://api.sprucehealth.com/v1/conversations/{{ $('Filter Inbound Messages').item.json.body.data.object.conversationId }}/messages",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "<redacted-credential>="
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"body\": [{\"type\": \"text\", \"value\": \"{{ (function() { const raw = $('Claude AI Response (Prospective)').item.json.choices[0].message.content; const clean = raw.replace(/^```json\\s*/i, '').replace(/^```\\s*/i, '').replace(/```\\s*$/i, '').trim(); return JSON.parse(clean).reply.replace(/\"/g, '\\\\\"').replace(/\\n/g, '\\\\n'); })() }}\"}]\n}",
        "options": {}
      },
      "id": "dcb2e14c-aa13-4f1e-b513-780b77bb6896",
      "name": "Reply to Patient (Prospective)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        384,
        1888
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://api.sprucehealth.com/v1/conversations/{{ $('Filter Inbound Messages').item.json.body.data.object.conversationId }}/messages",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "<redacted-credential>="
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"body\": [{\"type\": \"text\", \"value\": \"{{ (function() { const raw = $('Claude AI Response (Prospective)').item.json.choices[0].message.content; const clean = raw.replace(/^```json\\s*/i, '').replace(/^```\\s*/i, '').replace(/```\\s*$/i, '').trim(); return JSON.parse(clean).reply.replace(/\"/g, '\\\\\"').replace(/\\n/g, '\\\\n'); })() }}\"}]\n}",
        "options": {}
      },
      "id": "a2441824-bbf0-43f6-94a4-db896a86d3ef",
      "name": "Reply to Patient (Prospective Escalated)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        384,
        2048
      ]
    },
    {
      "parameters": {
        "url": "=https://api.sprucehealth.com/v1/conversations/{{ $('Filter Inbound Messages').item.json.body.data.object.conversationId }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "<redacted-credential>="
            }
          ]
        },
        "options": {}
      },
      "id": "a1b2c3d4-3333-4aaa-bbbb-000000000003",
      "name": "Re-fetch Conversation (Existing)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -176,
        2208
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 1
          },
          "conditions": [
            {
              "id": "reblock2",
              "leftValue": "={{ JSON.stringify($json.tags || []) }}",
              "rightValue": "block_chatbot",
              "operator": {
                "type": "string",
                "operation": "notContains"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "a1b2c3d4-4444-4aaa-bbbb-000000000004",
      "name": "Block Re-check (Existing)",
      "type": "n8n-nodes-base.filter",
      "typeVersion": 2,
      "position": [
        0,
        2208
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://api.sprucehealth.com/v1/conversations/{{ $('Filter Inbound Messages').item.json.body.data.object.conversationId }}/messages",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "<redacted-credential>="
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"body\": [{\"type\": \"text\", \"value\": \"{{ (function() { const raw = $('Claude AI Response (Existing)').item.json.choices[0].message.content; const clean = raw.replace(/^```json\\s*/i, '').replace(/^```\\s*/i, '').replace(/```\\s*$/i, '').trim(); return JSON.parse(clean).reply.replace(/\"/g, '\\\\\"').replace(/\\n/g, '\\\\n'); })() }}\"}]\n}",
        "options": {}
      },
      "id": "04bf355d-fed9-49d0-a62f-34f1c4900aba",
      "name": "Reply to Patient (Existing)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        176,
        2208
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://api.sprucehealth.com/v1/conversations/{{ $('Filter Inbound Messages').item.json.body.data.object.conversationId }}/messages",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "<redacted-credential>="
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"body\": [{\"type\": \"text\", \"value\": \"EXISTING PATIENT MESSAGE \u2014 needs care team follow-up.\\n\\nPatient: {{ $('Fetch Conversation').item.json.title || 'Unknown' }}\\nMessage: {{ $('Filter Inbound Messages').item.json.body.data.object.text.replace(/\"/g, '\\\\\"').replace(/\\n/g, '\\\\n') }}\"}],\n  \"internal\": true\n}",
        "options": {}
      },
      "id": "efbfd637-8d1d-420b-9904-2ad180e7473c",
      "name": "Post Existing Patient Note",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        384,
        2208
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://api.sprucehealth.com/v1/conversations/{{ $('Filter Inbound Messages').item.json.body.data.object.conversationId }}/messages",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "<redacted-credential>="
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"body\": [{\"type\": \"text\", \"value\": \"AUTO-ESCALATION: Prospective patient message needs care team review.\\n\\nPatient: {{ $('Fetch Conversation').item.json.title || 'Unknown' }}\\nMessage: {{ $('Filter Inbound Messages').item.json.body.data.object.text.replace(/\"/g, '\\\\\"').replace(/\\n/g, '\\\\n') }}\"}],\n  \"internal\": true\n}",
        "options": {}
      },
      "id": "f32c3e89-dfa9-43c8-85d1-3f1cd79a5c77",
      "name": "Post Escalation Note (Prospective)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        576,
        2048
      ]
    }
  ],
  "connections": {
    "Spruce Webhook": {
      "main": [
        [
          {
            "node": "Respond OK",
            "type": "main",
            "index": 0
          },
          {
            "node": "Filter Inbound Messages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Inbound Messages": {
      "main": [
        [
          {
            "node": "Fetch Conversation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Conversation": {
      "main": [
        [
          {
            "node": "Fetch Conversation Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Conversation Items": {
      "main": [
        [
          {
            "node": "Block Chatbot Check",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Block Chatbot Check": {
      "main": [
        [
          {
            "node": "Prospective or Existing?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prospective or Existing?": {
      "main": [
        [
          {
            "node": "Claude AI Response (Prospective)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Claude AI Response (Existing)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Claude AI Response (Prospective)": {
      "main": [
        [
          {
            "node": "Re-fetch Conversation (Prospective)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Re-fetch Conversation (Prospective)": {
      "main": [
        [
          {
            "node": "Block Re-check (Prospective)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Block Re-check (Prospective)": {
      "main": [
        [
          {
            "node": "Needs Escalation? (Prospective)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Needs Escalation? (Prospective)": {
      "main": [
        [
          {
            "node": "Reply to Patient (Prospective Escalated)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Reply to Patient (Prospective)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reply to Patient (Prospective Escalated)": {
      "main": [
        [
          {
            "node": "Post Escalation Note (Prospective)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Claude AI Response (Existing)": {
      "main": [
        [
          {
            "node": "Re-fetch Conversation (Existing)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Re-fetch Conversation (Existing)": {
      "main": [
        [
          {
            "node": "Block Re-check (Existing)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Block Re-check (Existing)": {
      "main": [
        [
          {
            "node": "Reply to Patient (Existing)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reply to Patient (Existing)": {
      "main": [
        [
          {
            "node": "Post Existing Patient Note",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "callerPolicy": "workflowsFromSameOwner",
    "availableInMCP": false
  },
  "versionId": "ada99ee0-0ca0-45a9-83d2-64cc97554d37",
  "id": "n9TDIr4fnPopD3cY",
  "tags": []
}