{
  "name": "AnyBio Govern: three drafts, one gate",
  "nodes": [
    {
      "parameters": {
        "content": "## AnyBio Govern, verification demo\nSandbox application, synthetic data. Nothing here reaches a real person.\n\nExecute once: A is delivered and its outcome reported. B is held as never sendable and its full decision record is fetched. C is delivered too, and the patient's own words open a hand-off to a person, recorded on the decision.",
        "height": 180,
        "width": 1180
      },
      "name": "About",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [0, 20]
    },
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [0, 340]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "7d1c0f52-0001-4e7a-9b4e-2a9d1e5f0001",
              "name": "conversationId",
              "value": "=n8n-demo-{{ $now.toMillis() }}",
              "type": "string"
            },
            {
              "id": "7d1c0f52-0002-4e7a-9b4e-2a9d1e5f0002",
              "name": "patientRef",
              "value": "synthetic-001",
              "type": "string"
            },
            {
              "id": "7d1c0f52-0003-4e7a-9b4e-2a9d1e5f0003",
              "name": "holdMessage",
              "value": "Thanks for your message. A member of your care team will follow up shortly.",
              "type": "string"
            },
            {
              "id": "7d1c0f52-0004-4e7a-9b4e-2a9d1e5f0004",
              "name": "disclosureText",
              "value": "Messages in this conversation are written by an automated assistant and checked before they are sent. Your care team reviews anything it is unsure about.",
              "type": "string"
            }
          ]
        },
        "includeOtherFields": false,
        "options": {}
      },
      "name": "Conversation",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [220, 340]
    },
    {
      "parameters": {
        "operation": "recordDisclosure",
        "conversationId": "={{ $json.conversationId }}",
        "channel": "app_message",
        "textShown": "={{ $json.disclosureText }}",
        "disclosureFields": {},
        "requestOptions": {}
      },
      "name": "Record Disclosure",
      "type": "n8n-nodes-anybio.anyBioGovern",
      "typeVersion": 1,
      "position": [440, 340]
    },
    {
      "parameters": {
        "jsCode": "// Three synthetic drafts for one conversation.\n// A is an ordinary check-in. B changes a medication. C answers a patient whose own words describe an emergency.\nconst settings = $('Conversation').first().json;\nconst disclosure = $input.first().json; // Record Disclosure output, carries ref\nconst stamp = Date.now();\nconst cases = [\n  { case: 'A. Ordinary check-in', draft: \"Thanks for sending today's reading. It is in your record, and your care team will look at it at your next check-in.\", inbound: '' },\n  { case: 'B. Medication change', draft: 'Your reading is high. Increase your dose of lisinopril to 20 mg starting today.', inbound: '' },\n  { case: \"C. Emergency in the patient's words\", draft: \"Thanks, I'll pass this along to your care team.\", inbound: 'I have chest pain and it is getting worse' },\n];\nreturn cases.map((c, i) => ({\n  json: {\n    ...c,\n    conversationId: settings.conversationId,\n    patientRef: settings.patientRef,\n    holdMessage: settings.holdMessage,\n    disclosureRef: disclosure.ref,\n    turnId: `${settings.conversationId}-${'ABC'[i]}-${stamp}`,\n  },\n}));"
      },
      "name": "Three drafts",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [660, 340]
    },
    {
      "parameters": {
        "operation": "evaluate",
        "draftText": "={{ $json.draft }}",
        "conversationId": "={{ $json.conversationId }}",
        "channel": "app_message",
        "audience": "patient",
        "patientRef": "={{ $json.patientRef }}",
        "holdMessage": "={{ $json.holdMessage }}",
        "additionalFields": {
          "turnId": "={{ $json.turnId }}",
          "inboundMessage": "={{ $json.inbound }}",
          "disclosureRef": "={{ $json.disclosureRef }}",
          "model": "scripted-demo"
        },
        "requestOptions": {}
      },
      "name": "AnyBio Govern",
      "type": "n8n-nodes-anybio.anyBioGovern",
      "typeVersion": 1,
      "position": [880, 340]
    },
    {
      "parameters": {},
      "name": "Deliver to the patient",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [1140, 200]
    },
    {
      "parameters": {},
      "name": "Show the hold text",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [1140, 340]
    },
    {
      "parameters": {},
      "name": "Send nothing",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [1140, 480]
    },
    {
      "parameters": {
        "operation": "reportOutcome",
        "decisionId": "={{ $json.decisionId }}",
        "delivered": true,
        "deliveredText": "={{ $json.text }}",
        "outcomeFields": {},
        "requestOptions": {}
      },
      "name": "Report Delivered",
      "type": "n8n-nodes-anybio.anyBioGovern",
      "typeVersion": 1,
      "position": [1380, 200]
    },
    {
      "parameters": {
        "operation": "getDecision",
        "decisionId": "={{ $json.decisionId }}",
        "requestOptions": {}
      },
      "name": "Get Decision",
      "type": "n8n-nodes-anybio.anyBioGovern",
      "typeVersion": 1,
      "position": [1380, 340]
    }
  ],
  "connections": {
    "Start": { "main": [[{ "node": "Conversation", "type": "main", "index": 0 }]] },
    "Conversation": { "main": [[{ "node": "Record Disclosure", "type": "main", "index": 0 }]] },
    "Record Disclosure": { "main": [[{ "node": "Three drafts", "type": "main", "index": 0 }]] },
    "Three drafts": { "main": [[{ "node": "AnyBio Govern", "type": "main", "index": 0 }]] },
    "AnyBio Govern": {
      "main": [
        [{ "node": "Deliver to the patient", "type": "main", "index": 0 }],
        [{ "node": "Show the hold text", "type": "main", "index": 0 }],
        [{ "node": "Send nothing", "type": "main", "index": 0 }]
      ]
    },
    "Deliver to the patient": { "main": [[{ "node": "Report Delivered", "type": "main", "index": 0 }]] },
    "Show the hold text": { "main": [[{ "node": "Get Decision", "type": "main", "index": 0 }]] }
  },
  "pinData": {},
  "settings": { "executionOrder": "v1" }
}
