{
  "name": "AI Approval with Verifiable Decision Receipts",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "ai-approval",
        "options": {},
        "responseMode": "responseNode"
      },
      "id": "1363d2c1-f0b0-443c-adba-64e389173e8c",
      "name": "Incoming Request",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        0,
        300
      ]
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o",
          "cachedResultName": "GPT-4O"
        },
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "=You are an autonomous approval agent for an enterprise. Given a request, decide APPROVE or REJECT with a short reason. Return strict JSON: {\"decision\":\"APPROVE|REJECT\",\"reason\":\"...\",\"confidence\":0-100}."
            },
            {
              "content": "=Evaluate this request and respond with the JSON only.\n\nRequest:\n{{ $json.body.request }}"
            }
          ]
        },
        "jsonOutput": true,
        "options": {}
      },
      "id": "116ab252-5c9e-46fa-a39c-834f91aba8c2",
      "name": "AI Decision (Approve/Reject)",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 2.1,
      "position": [
        240,
        300
      ],
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "id": "55b6c834-aa54-4dbc-ae5a-0ced72778c56",
              "leftValue": "={{ $json.message.content.decision }}",
              "rightValue": "APPROVE",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "4a84e8e8-0cab-4296-8c12-cb6e69076f05",
      "name": "IF Approved",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        480,
        300
      ]
    },
    {
      "parameters": {
        "operation": "generateReceipt",
        "agentName": "EnterpriseApprovalAgent",
        "workflowName": "={{ $workflow.name }}",
        "action": "={{ 'AI ' + $json.message.content.decision + ' on request' }}",
        "decision": "={{ JSON.stringify($json.message.content) }}",
        "additionalFields": {
          "modelProvider": "openai",
          "modelUsed": "gpt-4o",
          "decisionType": "approval",
          "riskLevel": "high",
          "humanReview": false,
          "policies": "internal-approval-v1, eu-ai-act-high-risk",
          "permissions": "request.decide",
          "tags": "approval, governance",
          "inputPrompt": "={{ $('Incoming Request').item.json.body.request }}"
        }
      },
      "id": "bb4c64b0-9794-4888-b73d-75ab1b88f733",
      "name": "Signatrust: Generate Receipt",
      "type": "n8n-nodes-signatrust.signatrust",
      "typeVersion": 1,
      "position": [
        720,
        200
      ],
      "credentials": {
        "signatrustApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ { \"status\": \"APPROVED\", \"receipt_id\": $json.id, \"receipt\": $json } }}",
        "options": {}
      },
      "id": "fdf771b3-f80d-4c43-b889-55c02ee0f2ce",
      "name": "Respond Approved",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        960,
        200
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ { \"status\": \"REJECTED\", \"detail\": $('AI Decision (Approve/Reject)').item.json.message.content } }}",
        "options": {}
      },
      "id": "6bc2d1e2-9327-431d-ba8a-bd3fdc90a3dc",
      "name": "Respond Rejected",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        720,
        440
      ]
    },
    {
      "parameters": {
        "content": "## AI Approval + Signatrust\nAn AI agent approves or rejects an incoming request. **Every approval produces a cryptographically signed Decision Receipt** so you can later prove *what* was decided, *why*, *which model*, and under *which policy*.",
        "height": 200,
        "width": 420,
        "color": 5
      },
      "id": "314cc660-1d6c-4e87-a247-a66282c1ac77",
      "name": "Sticky Note ca44e2",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -40,
        40
      ]
    },
    {
      "parameters": {
        "content": "### Why Signatrust?\nWithout a receipt, an AI 'approve' is just a log line. With Signatrust it becomes tamper-evident, Ed25519-signed, and independently verifiable for audits (EU AI Act, SOC 2, internal governance).",
        "height": 170,
        "width": 380,
        "color": 6
      },
      "id": "e5e63090-cb4f-4d52-a86a-82eb9e1e92b1",
      "name": "Sticky Note fd8d7e",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        720,
        20
      ]
    }
  ],
  "connections": {
    "Incoming Request": {
      "main": [
        [
          {
            "node": "AI Decision (Approve/Reject)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Decision (Approve/Reject)": {
      "main": [
        [
          {
            "node": "IF Approved",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF Approved": {
      "main": [
        [
          {
            "node": "Signatrust: Generate Receipt",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Respond Rejected",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Signatrust: Generate Receipt": {
      "main": [
        [
          {
            "node": "Respond Approved",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "tags": [
    {
      "name": "AI Approval \u2014 AI"
    },
    {
      "name": "AI Approval \u2014 Governance"
    },
    {
      "name": "Signatrust"
    },
    {
      "name": "AI Approval \u2014 Approval"
    }
  ],
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "versionId": "23cf0d5c-a757-4047-9224-d536c51b9627"
}