{
  "name": "YES NO - Lead qualification",
  "nodes": [
    {
      "parameters": {},
      "id": "start",
      "name": "Run manually",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "source-id",
              "name": "source_id",
              "value": "example-lead",
              "type": "string"
            },
            {
              "id": "request-id",
              "name": "request_id",
              "value": "={{ 'check-' + $execution.id + '-' + $itemIndex }}",
              "type": "string"
            },
            {
              "id": "question",
              "name": "question",
              "value": "Is this a business enquiry about commissioning a new website, with a stated budget of at least $3,000?",
              "type": "string"
            },
            {
              "id": "text",
              "name": "text",
              "value": "Hi, we run an accountancy practice and need a new website for our business. Our budget is $6,000. Could you send a proposal and arrange a call next week?",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "input",
      "name": "Input item",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        240,
        0
      ],
      "notes": "Fictional sample. Replace the manual trigger with your source event and map its text and item ID here. The sample request ID is stable for node retries within this execution. For cross-execution retries, use a unique source event ID plus check version; change the ID whenever the question or text changes."
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://answeryesno.com/v1/check",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Idempotency-Key",
              "value": "={{ $json.request_id }}"
            }
          ]
        },
        "sendBody": true,
        "contentType": "json",
        "specifyBody": "keypair",
        "bodyParameters": {
          "parameters": [
            {
              "name": "question",
              "value": "={{ $json.question }}"
            },
            {
              "name": "text",
              "value": "={{ $json.text }}"
            }
          ]
        },
        "options": {
          "timeout": 100000,
          "batching": {
            "batch": {
              "batchSize": 1,
              "batchInterval": 1000
            }
          },
          "response": {
            "response": {
              "responseFormat": "json",
              "neverError": false
            }
          }
        }
      },
      "id": "check",
      "name": "Binary check",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        480,
        0
      ],
      "notes": "Choose a Header Auth credential: Name Authorization, Value Bearer YOUR_API_KEY. Set a service URL reachable from your n8n instance. Request failures stop this workflow; never treat an error as NO. One successful check uses one credit; same-ID retries with identical input are replayed free for seven days."
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "result",
              "leftValue": "={{ $json.result }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "branch",
      "name": "YES or NO",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        720,
        0
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "source-id",
              "name": "source_id",
              "value": "={{ $('Input item').item.json.source_id }}",
              "type": "string"
            },
            {
              "id": "text",
              "name": "text",
              "value": "={{ $('Input item').item.json.text }}",
              "type": "string"
            },
            {
              "id": "question",
              "name": "question",
              "value": "={{ $('Input item').item.json.question }}",
              "type": "string"
            },
            {
              "id": "result",
              "name": "result",
              "value": "={{ $json.result }}",
              "type": "boolean"
            }
          ]
        },
        "options": {}
      },
      "id": "yes",
      "name": "YES - connect your action",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        960,
        -120
      ],
      "notes": "This node only restores the original item beside the answer. Attach your action for a supported question. Test the rule on representative examples before enabling store actions."
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "source-id",
              "name": "source_id",
              "value": "={{ $('Input item').item.json.source_id }}",
              "type": "string"
            },
            {
              "id": "text",
              "name": "text",
              "value": "={{ $('Input item').item.json.text }}",
              "type": "string"
            },
            {
              "id": "question",
              "name": "question",
              "value": "={{ $('Input item').item.json.question }}",
              "type": "string"
            },
            {
              "id": "result",
              "name": "result",
              "value": "={{ $json.result }}",
              "type": "boolean"
            }
          ]
        },
        "options": {}
      },
      "id": "no",
      "name": "NO - connect your action",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        960,
        120
      ],
      "notes": "This node only restores the original item beside the answer. NO means the text does not establish the question; it does not independently prove a fact false. Attach your fallback or review action."
    }
  ],
  "connections": {
    "Run manually": {
      "main": [
        [
          {
            "node": "Input item",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Input item": {
      "main": [
        [
          {
            "node": "Binary check",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Binary check": {
      "main": [
        [
          {
            "node": "YES or NO",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "YES or NO": {
      "main": [
        [
          {
            "node": "YES - connect your action",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "NO - connect your action",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "active": false
}