{
  "name": "AI Agent Chain of Custody (Signatrust flagship demo)",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "chain-of-custody",
        "options": {},
        "responseMode": "responseNode"
      },
      "id": "09962955-c6dd-4f03-af0f-7b4458b2741a",
      "name": "User Request",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        0,
        400
      ]
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o",
          "cachedResultName": "GPT-4O"
        },
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "=You are Agent #1 (Intake). Analyze the user request and produce a plan. Return JSON: {\"plan\":\"...\",\"needs_tool\":true,\"summary\":\"...\"}."
            },
            {
              "content": "=Plan this request. JSON only.\n\n{{ $json.body.request }}"
            }
          ]
        },
        "jsonOutput": true,
        "options": {}
      },
      "id": "8a64eaa0-8636-488e-b2f7-dd8eaf1c0610",
      "name": "Agent 1: Intake & Plan",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 2.1,
      "position": [
        220,
        400
      ],
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "generateReceipt",
        "agentName": "IntakeAgent",
        "workflowName": "={{ $workflow.name }}",
        "action": "Produced execution plan",
        "decision": "={{ JSON.stringify($json.message.content) }}",
        "additionalFields": {
          "modelProvider": "openai",
          "modelUsed": "gpt-4o",
          "decisionType": "agent_plan",
          "riskLevel": "low",
          "humanReview": false,
          "tags": "chain-of-custody, step-1, intake"
        }
      },
      "id": "0779392b-a58b-4a9e-aa90-6c8d61c3e989",
      "name": "Receipt 1: Intake",
      "type": "n8n-nodes-signatrust.signatrust",
      "typeVersion": 1,
      "position": [
        440,
        400
      ],
      "credentials": {
        "signatrustApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "GET",
        "url": "https://httpbin.org/get?q={{ $('User Request').item.json.body.request }}",
        "options": {}
      },
      "id": "9fb9e4c6-1ede-44bf-9fd4-2652fd71074d",
      "name": "Tool Execution",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        660,
        400
      ]
    },
    {
      "parameters": {
        "operation": "generateReceipt",
        "agentName": "ToolAgent",
        "workflowName": "={{ $workflow.name }}",
        "action": "Executed external tool / data fetch",
        "decision": "={{ JSON.stringify($json) }}",
        "additionalFields": {
          "modelProvider": "openai",
          "modelUsed": "gpt-4o",
          "decisionType": "tool_execution",
          "riskLevel": "medium",
          "humanReview": false,
          "permissions": "tool.execute",
          "tags": "chain-of-custody, step-2, tool"
        }
      },
      "id": "cb18098b-fa5d-4c05-a578-f69b59b567ca",
      "name": "Receipt 2: Tool Call",
      "type": "n8n-nodes-signatrust.signatrust",
      "typeVersion": 1,
      "position": [
        880,
        400
      ],
      "credentials": {
        "signatrustApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o",
          "cachedResultName": "GPT-4O"
        },
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "=You are Agent #2 (Synthesizer). Combine the plan and tool result into a final recommendation. Return JSON: {\"recommendation\":\"...\",\"risk\":\"low|medium|high\"}."
            },
            {
              "content": "=Plan:\n{{ $('Agent 1: Intake & Plan').item.json.message.content }}\n\nTool result:\n{{ $('Tool Execution').item.json }}\n\nReturn JSON only."
            }
          ]
        },
        "jsonOutput": true,
        "options": {}
      },
      "id": "07f8cdcb-114f-4bc0-b0df-f898fe7b2664",
      "name": "Agent 2: Synthesize",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 2.1,
      "position": [
        1100,
        400
      ],
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "generateReceipt",
        "agentName": "SynthesizerAgent",
        "workflowName": "={{ $workflow.name }}",
        "action": "Produced final recommendation",
        "decision": "={{ JSON.stringify($json.message.content) }}",
        "additionalFields": {
          "modelProvider": "openai",
          "modelUsed": "gpt-4o",
          "decisionType": "agent_recommendation",
          "riskLevel": "={{ $json.message.content.risk }}",
          "humanReview": false,
          "tags": "chain-of-custody, step-3, synthesis"
        }
      },
      "id": "ed390024-de7c-4c8a-94f7-30de13f64e55",
      "name": "Receipt 3: Synthesis",
      "type": "n8n-nodes-signatrust.signatrust",
      "typeVersion": 1,
      "position": [
        1320,
        400
      ],
      "credentials": {
        "signatrustApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a8917090-98bf-4dae-aab1-89f832d51891",
              "name": "approved_by",
              "value": "compliance@yourcompany.com",
              "type": "string"
            },
            {
              "id": "d6fd4d7d-7310-4cb2-b765-72ce5516d5c9",
              "name": "approved",
              "value": "true",
              "type": "boolean"
            }
          ]
        },
        "options": {}
      },
      "id": "e15e8e4e-e7cb-4101-bf6c-4af6b198dea0",
      "name": "Human Approval (gate)",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1540,
        400
      ]
    },
    {
      "parameters": {
        "operation": "generateReceipt",
        "agentName": "HumanGate",
        "workflowName": "={{ $workflow.name }}",
        "action": "Human approved the AI recommendation",
        "decision": "={{ { approved: $json.approved, approved_by: $json.approved_by } }}",
        "additionalFields": {
          "modelProvider": "human",
          "decisionType": "human_approval",
          "riskLevel": "high",
          "humanReview": true,
          "permissions": "decision.approve",
          "tags": "chain-of-custody, step-4, human"
        }
      },
      "id": "6d0f7607-ffe1-49c8-80b4-148cbb0a8694",
      "name": "Receipt 4: Human Approval",
      "type": "n8n-nodes-signatrust.signatrust",
      "typeVersion": 1,
      "position": [
        1760,
        400
      ],
      "credentials": {
        "signatrustApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://httpbin.org/post",
        "options": {},
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "chain_receipts",
              "value": "={{ [$('Receipt 1: Intake').item.json.id, $('Receipt 2: Tool Call').item.json.id, $('Receipt 3: Synthesis').item.json.id, $json.id] }}"
            }
          ]
        }
      },
      "id": "ac7f66d5-2fbf-4af4-ab0d-95bb47540a2f",
      "name": "Execute Action",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1980,
        400
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ { status:\"DONE\", chain:[ $('Receipt 1: Intake').item.json.id, $('Receipt 2: Tool Call').item.json.id, $('Receipt 3: Synthesis').item.json.id, $('Receipt 4: Human Approval').item.json.id ] } }}",
        "options": {}
      },
      "id": "04098dd7-31a4-467d-a91b-95733c2b78e4",
      "name": "Respond with Full Chain",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        2200,
        400
      ]
    },
    {
      "parameters": {
        "content": "## \u2b50 AI Agent Chain of Custody\nThe flagship demo. **Every single step** \u2014 intake, tool call, synthesis, human approval, execution \u2014 emits its own Signatrust receipt. The result is an unbroken, cryptographically verifiable chain of custody for a multi-agent decision.",
        "height": 240,
        "width": 460,
        "color": 3
      },
      "id": "a7b49a57-2b13-4191-806a-b7f7a094b3c5",
      "name": "Sticky Note 888670",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -60,
        120
      ]
    },
    {
      "parameters": {
        "content": "### Why this matters\nFor regulated AI (finance, health, legal), you must prove the *entire* decision lineage \u2014 not just the final answer. This workflow shows Signatrust as the audit backbone across agents and humans.",
        "height": 180,
        "width": 420,
        "color": 6
      },
      "id": "87ac4118-8f39-4db0-9b4c-9a69bb0f16ad",
      "name": "Sticky Note 5d9308",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1100,
        120
      ]
    }
  ],
  "connections": {
    "User Request": {
      "main": [
        [
          {
            "node": "Agent 1: Intake & Plan",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Agent 1: Intake & Plan": {
      "main": [
        [
          {
            "node": "Receipt 1: Intake",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Receipt 1: Intake": {
      "main": [
        [
          {
            "node": "Tool Execution",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Tool Execution": {
      "main": [
        [
          {
            "node": "Receipt 2: Tool Call",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Receipt 2: Tool Call": {
      "main": [
        [
          {
            "node": "Agent 2: Synthesize",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Agent 2: Synthesize": {
      "main": [
        [
          {
            "node": "Receipt 3: Synthesis",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Receipt 3: Synthesis": {
      "main": [
        [
          {
            "node": "Human Approval (gate)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Human Approval (gate)": {
      "main": [
        [
          {
            "node": "Receipt 4: Human Approval",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Receipt 4: Human Approval": {
      "main": [
        [
          {
            "node": "Execute Action",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute Action": {
      "main": [
        [
          {
            "node": "Respond with Full Chain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "tags": [
    {
      "name": "AI Agent Chain of Custody \u2014 Agent"
    },
    {
      "name": "AI Agent Chain of Custody \u2014 ChainOfCustody"
    },
    {
      "name": "Signatrust (6)"
    },
    {
      "name": "AI Agent Chain of Custody \u2014 Governance"
    }
  ],
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "versionId": "4131a9e6-63ba-4910-9bb4-9dcff575c130"
}