{
  "name": "Ratifia: ask with a draft, then hand off (community node)",
  "nodes": [
    {
      "parameters": {
        "content": "## Ask with a draft, then hand off\n\nOne **Request Approval and Wait** replaces the hash, the create call, the wait and the poll loop. It also sends a **Draft for Review**, so the reviewer can rewrite the reply in Ratifia, by hand or with Refine with AI, before approving.\n\nThe facts bind **receiptId, recipient and amount**, read from the receipt rather than typed into the workflow. The body is not bound, which is what lets the reviewer edit it.\n\nIt hands the child only **receiptId, decisionId and the approved body**. The child looks the amount up again for itself, so nothing this workflow says about the money is taken on trust.\n\nOn approve the node returns `output`: their edit when they made one, your original when they did not. **Send `output`.**\n\nAfter importing both, publish the child and point **Send it (protected)** at it.",
        "height": 360,
        "width": 560
      },
      "id": "60fdb21a-4594-4b19-8295-1e00258b7769",
      "name": "Note e821c8",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {},
      "id": "80723008-f5f3-448f-bf56-f592d1239df9",
      "name": "Run it",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        300
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a112c9f8-c501-4380-b1c3-137824ef1cb4",
              "name": "receiptId",
              "value": "rcpt_INV-2291",
              "type": "string"
            },
            {
              "id": "ca445691-089d-497e-97f6-dda57f6c75a5",
              "name": "body",
              "value": "Hi Dana,\n\nWe've refunded the duplicate charge of $620.00 to the card ending 4242. It should appear within 5 business days.\n\nThanks for your patience,\nAcme Support",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "50f2c768-0ff0-43fe-a28f-6767b9f73b59",
      "name": "The refund",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        220,
        300
      ]
    },
    {
      "parameters": {
        "url": "=https://your-system.example/receipts/{{ $json.receiptId }}",
        "options": {
          "timeout": 30000
        }
      },
      "id": "053596fa-bc2e-4857-bbe3-37316aedcf79",
      "name": "Look up the receipt",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        440,
        300
      ]
    },
    {
      "parameters": {
        "operation": "requestAndWait",
        "prompt": "=Refund {{ $json.amount }} to {{ $json.recipient }} for receipt {{ $(\"The refund\").item.json.receiptId }}?",
        "policy": "customer-replies",
        "factsTable": {
          "fact": [
            {
              "name": "receiptId",
              "type": "string",
              "value": "={{ $(\"The refund\").item.json.receiptId }}",
              "showReviewer": true,
              "src": "tool"
            },
            {
              "name": "recipient",
              "type": "string",
              "value": "={{ $(\"Look up the receipt\").item.json.recipient }}",
              "showReviewer": true,
              "src": "tool"
            },
            {
              "name": "amount",
              "type": "number",
              "value": "={{ $(\"Look up the receipt\").item.json.amount }}",
              "showReviewer": true,
              "src": "tool"
            }
          ]
        },
        "proposedOutput": {
          "title": "=Reply to {{ $json.recipient }}",
          "content": "={{ $(\"The refund\").item.json.body }}"
        },
        "options": {
          "title": "=Refund for receipt {{ $(\"The refund\").item.json.receiptId }}",
          "workflowRef": "customer-replies"
        },
        "waitOptions": {
          "pollIntervalSec": 15,
          "maxWaitMinutes": 60
        }
      },
      "id": "3a087023-5121-4742-8771-4b9b93546c11",
      "name": "Ask for approval",
      "type": "n8n-nodes-ratifia.ratifia",
      "typeVersion": 1,
      "position": [
        660,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "adf572e7-8350-4e41-a4db-7f4e14bcb9d9",
              "leftValue": "={{ $json.approved }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "b1597d4f-c777-465a-a2d6-789d60f9896c",
      "name": "Approved?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        880,
        300
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "9a70cabb-28a1-495d-bf7c-635a4884035e",
              "name": "receiptId",
              "value": "={{ $(\"The refund\").item.json.receiptId }}",
              "type": "string"
            },
            {
              "id": "cde8ece0-3b6b-438c-9a79-1279a58d7311",
              "name": "body",
              "value": "={{ $(\"Ask for approval\").item.json.output.content }}",
              "type": "string"
            },
            {
              "id": "6b8355f8-eb1e-4699-a4d5-919128b97f90",
              "name": "decisionId",
              "value": "={{ $(\"Ask for approval\").item.json.id }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "d50a8585-e94e-4424-8292-ea8888e45d5b",
      "name": "Hand off",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1100,
        220
      ]
    },
    {
      "parameters": {
        "workflowId": {
          "__rl": true,
          "value": "REPLACE_WITH_CHILD_WORKFLOW_ID",
          "mode": "id"
        },
        "options": {}
      },
      "id": "a29c6097-9485-4bc1-bbe6-1aab4404596a",
      "name": "Send it (protected)",
      "type": "n8n-nodes-base.executeWorkflow",
      "typeVersion": 1.2,
      "position": [
        1320,
        220
      ]
    },
    {
      "parameters": {},
      "id": "d39b3528-166a-4eb7-b88a-8beed724e687",
      "name": "Not approved",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1100,
        420
      ]
    }
  ],
  "connections": {
    "Run it": {
      "main": [
        [
          {
            "node": "The refund",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "The refund": {
      "main": [
        [
          {
            "node": "Look up the receipt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Look up the receipt": {
      "main": [
        [
          {
            "node": "Ask for approval",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Ask for approval": {
      "main": [
        [
          {
            "node": "Approved?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Approved?": {
      "main": [
        [
          {
            "node": "Hand off",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Not approved",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Hand off": {
      "main": [
        [
          {
            "node": "Send it (protected)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}
