{
  "name": "Turn Google Sheets contacts into controlled Ringee AI call batches",
  "nodes": [
    {
      "parameters": {
        "errorMessage": "A service step failed. Inspect the failed execution and the source record. Reconcile any accepted Ringee call before retrying; never change its call key to bypass an ambiguous failure."
      },
      "id": "f2f3be5e-7808-4606-8c4b-8577a2abf5f9",
      "name": "Failure requires reconciliation",
      "type": "n8n-nodes-base.stopAndError",
      "typeVersion": 1,
      "position": [
        2300,
        1700
      ]
    },
    {
      "parameters": {
        "content": "### How it works\nA manual run reads ready sheet rows, normalizes international phone numbers and separates held records. At most the configured one-to-five eligible records proceed serially. Each call uses the persistent row identity and writes its actual result back to the same row. There is no automatic redial.\n\nThis template is for Operations teams and agencies managing consented customer call queues. A small calling queue with traceable results and explicit hold reasons. Ringee runs the voice conversation; n8n manages the surrounding records and decisions.\n\n### Setup\nInstall the verified **n8n-nodes-ringee 0.1.2** package. Create a Ringee account and a workspace Custom Integration, then select its API key in an n8n credential. Choose your already configured voice agent, keep callsEnabled false, and configure permission evidence, recipient timezones and a unique client namespace. Connect Google Sheets, Slack and select every blank destination. Signed triggers also need the Signing Secret and the integration Outbound URL. Import into a new inactive workflow and test dedicated demonstration records before activation.\n\n### Customization\nStart with one authorized call per run. Change calling days and hours for your recipients; this does not establish legal compliance. No automatic redial is included. Read the companion setup guide for column names, field mappings and limitations. [Create your Ringee account](https://ringee.io/integrations/n8n?utm_source=n8n&utm_medium=template&utm_campaign=ringee_workflows&utm_content=11-controlled-sheet-calling).",
        "width": 570,
        "height": 700,
        "color": 1
      },
      "id": "3724282e-d5c5-4279-8efb-656f1567193f",
      "name": "Overview",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -600,
        -320
      ]
    },
    {
      "parameters": {
        "content": "## Configure the source\nSelect credentials and destinations. Calling workflows require trusted permission evidence and an IANA timezone for each recipient.",
        "width": 1600,
        "height": 400,
        "color": 7
      },
      "id": "7ede8d4f-ecb3-4b32-85f1-3a587caad8fe",
      "name": "1. Configure and admit records",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        80
      ]
    },
    {
      "parameters": {
        "content": "## Control billable work\nThe model cannot grant consent. Keep persistent keys, serial processing and the one-to-five call cap. Ringee also enforces its financial, DNC and capacity gates.",
        "width": 1500,
        "height": 470,
        "color": 7
      },
      "id": "c734a874-b31b-49f3-8b5a-d07eb8340e58",
      "name": "2. One authorized call",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1650,
        80
      ]
    },
    {
      "parameters": {
        "content": "## Wait for real results\nCompletion and analysis are separate. Two bounded reads preserve pending or missing-analysis states. Failures require inspection; a result read never starts a call.",
        "width": 1400,
        "height": 470,
        "color": 7
      },
      "id": "5d92c204-0ab8-4161-89ef-7baa85bc4ab4",
      "name": "3. Reconcile the result",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        3200,
        80
      ]
    },
    {
      "parameters": {
        "content": "## Persist attempts in the source queue\nSelect the same source document and tab in the initial read, refresh read and result write. The result updates attemptCount and status so later polls can process remaining records.",
        "width": 1900,
        "height": 470,
        "color": 7
      },
      "id": "1525142c-7396-44bd-8bbf-ed1a0cfab851",
      "name": "4. Deliver the business outcome",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        4650,
        80
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "4e8f8080-279c-432c-8ac4-141b1169cbc6",
              "name": "callsEnabled",
              "value": false,
              "type": "boolean"
            },
            {
              "id": "c1c422e9-d23f-45f1-88e2-a7c8a3b00ca7",
              "name": "clientNamespace",
              "value": "CHANGE_ME_CLIENT_NAMESPACE",
              "type": "string"
            },
            {
              "id": "b07a4d3f-9fea-4de5-87f6-35b25a18b454",
              "name": "maxCallsPerRun",
              "value": 1,
              "type": "number"
            },
            {
              "id": "542c5444-3f7c-445a-80d6-a7a2fac4693d",
              "name": "startHour",
              "value": 9,
              "type": "number"
            },
            {
              "id": "8d2b9b8c-0622-494a-87fa-e7b5c5685a42",
              "name": "endHour",
              "value": 17,
              "type": "number"
            },
            {
              "id": "a5dd9a38-9346-4d5d-8a91-ba2b5fb636dd",
              "name": "callingDays",
              "value": "1,2,3,4,5",
              "type": "string"
            }
          ]
        },
        "includeOtherFields": true,
        "options": {}
      },
      "id": "42950067-a1df-476f-8da3-4c42e893d53c",
      "name": "Configuration",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.5,
      "position": [
        260,
        300
      ]
    },
    {
      "parameters": {},
      "id": "a27e5a43-8b3d-4517-8b20-d21e0a41a351",
      "name": "Held for manual review",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1800,
        700
      ]
    },
    {
      "parameters": {},
      "id": "d9655437-0c59-47fe-82d6-853171182ac0",
      "name": "Run approved queue",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        300
      ]
    },
    {
      "parameters": {
        "resource": "sheet",
        "operation": "read",
        "documentId": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "sheetName": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "options": {}
      },
      "id": "821af1cf-9a20-4a8b-8254-108f8029e2b6",
      "name": "Read approved source rows",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        520,
        300
      ],
      "onError": "continueErrorOutput",
      "alwaysOutputData": true
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "function normalizeRecords(items, config, now, kind, sourceEvent = null) {\n\tconst yes = (v) => v === true || String(v).trim().toLowerCase() === 'true';\n\tconst no = (v) => v === false || String(v).trim().toLowerCase() === 'false';\n\tconst cleanPhone = (v) => {\n\t\tconst text = String(v ?? '').trim();\n\t\tif (!/^(?:\\+|00)[\\d\\s().-]+$/.test(text)) return '';\n\t\treturn text.replace(/^00/, '+').replace(/[\\s().-]/g, '');\n\t};\n\tconst safeId = (v) => /^[A-Za-z0-9_.:@/+~=-]{1,120}$/.test(String(v ?? ''));\n\tconst namespace = String(config.clientNamespace ?? '');\n\tconst limit = Math.max(1, Math.min(5, Math.floor(Number(config.maxCallsPerRun) || 1)));\n\tconst seen = new Set();\n\tlet accepted = 0;\n\treturn items.map((item, index) => {\n\t\tlet row = { ...(item.json.body ?? item.json) };\n\t\tlet extra = {};\n\t\tif (kind === 'appointment' && row.eventId) {\n\t\t\textra = {\n\t\t\t\teventId: row.eventId,\n\t\t\t\tappointmentStart: row.appointmentStart,\n\t\t\t\ttitle: row.title,\n\t\t\t\tinReminderWindow: Date.parse(row.appointmentStart ?? '') > now.toMillis(),\n\t\t\t};\n\t\t} else if (kind === 'appointment') {\n\t\t\tconst description = String(row.description ?? '');\n\t\t\tconst line = (key) =>\n\t\t\t\tdescription.match(new RegExp('^' + key + ':[ \\\\t]*([^\\\\r\\\\n]*)', 'im'))?.[1]?.trim() ?? '';\n\t\t\tconst startMillis = Date.parse(row.start?.dateTime ?? '');\n\t\t\tconst anchor = Date.parse(config.runStartedAt ?? '') || now.toMillis();\n\t\t\tconst minutes = (startMillis - anchor) / 60000;\n\t\t\textra = {\n\t\t\t\teventId: row.id,\n\t\t\t\tappointmentStart: row.start?.dateTime ?? '',\n\t\t\t\ttitle: row.summary ?? 'Appointment',\n\t\t\t\tinReminderWindow:\n\t\t\t\t\tNumber.isFinite(startMillis) &&\n\t\t\t\t\tminutes >= Number(config.reminderMinutes) &&\n\t\t\t\t\tminutes < Number(config.reminderMinutes) + 15 &&\n\t\t\t\t\trow.status !== 'cancelled',\n\t\t\t};\n\t\t\trow = {\n\t\t\t\trecordId: row.id,\n\t\t\t\tphone: line('Phone'),\n\t\t\t\tname: line('Name'),\n\t\t\t\ttimezone: line('Timezone'),\n\t\t\t\tconsent: line('Consent'),\n\t\t\t\tconsentRecordedAt: line('ConsentRecordedAt'),\n\t\t\t\tauthorized: line('Authorized'),\n\t\t\t\tsuppressionChecked: line('SuppressionChecked'),\n\t\t\t\tdoNotCall: line('DoNotCall'),\n\t\t\t\tattemptCount: line('AttemptCount'),\n\t\t\t\temail: line('Email'),\n\t\t\t};\n\t\t}\n\t\tif (kind === 'callback') {\n\t\t\tconst event = sourceEvent ?? {};\n\t\t\tconst data = event.data ?? {};\n\t\t\tconst timestamp = Date.parse(event.occurredAt ?? '');\n\t\t\tconst age = now.toMillis() - timestamp;\n\t\t\tconst isInboundMiss =\n\t\t\t\tevent.event === 'call.missed' &&\n\t\t\t\t(data.direction === 'inbound' || data.call?.direction === 'inbound') &&\n\t\t\t\t!data.agent &&\n\t\t\t\t!data.call?.voiceAgentCall &&\n\t\t\t\t!String(data.externalId ?? '').startsWith('ringee-callback:') &&\n\t\t\t\tage >= 0 &&\n\t\t\t\tage <= 30 * 60000;\n\t\t\textra = { eventId: event.eventId, missedCallId: data.callId, isInboundMiss };\n\t\t\trow = { ...row, recordId: data.callId, phone: data.fromNumber, name: row.name ?? 'Caller' };\n\t\t}\n\t\tconst phone = cleanPhone(row.phone);\n\t\tconst local = now.setZone(String(row.timezone ?? ''));\n\t\tconst reasons = [];\n\t\tif (!yes(config.callsEnabled)) reasons.push('calls_disabled');\n\t\tif (!/^[A-Za-z0-9_.-]{1,120}$/.test(namespace) || namespace.includes('CHANGE_ME'))\n\t\t\treasons.push('configure_client_namespace');\n\t\tif (!safeId(row.recordId)) reasons.push('missing_or_invalid_record_id');\n\t\tif (!/^\\+[1-9]\\d{7,14}$/.test(phone)) reasons.push('invalid_e164_phone');\n\t\tif (!yes(row.authorized) || !yes(row.consent)) reasons.push('authorization_or_consent_missing');\n\t\tconst consentAt = Date.parse(row.consentRecordedAt ?? '');\n\t\tif (!Number.isFinite(consentAt) || consentAt > now.toMillis())\n\t\t\treasons.push('invalid_consent_timestamp');\n\t\tif (!yes(row.suppressionChecked) || !no(row.doNotCall))\n\t\t\treasons.push('suppression_check_required');\n\t\tif (\n\t\t\t!(\n\t\t\t\trow.attemptCount === 0 ||\n\t\t\t\t(typeof row.attemptCount === 'string' && row.attemptCount.trim() === '0')\n\t\t\t)\n\t\t)\n\t\t\treasons.push('already_attempted_or_attempt_count_missing');\n\t\tconst startHour = Number(config.startHour);\n\t\tconst endHour = Number(config.endHour);\n\t\tconst days = String(config.callingDays ?? '')\n\t\t\t.split(',')\n\t\t\t.map(Number);\n\t\tif (!local.isValid || !String(row.timezone ?? '').includes('/'))\n\t\t\treasons.push('recipient_iana_timezone_required');\n\t\telse if (\n\t\t\t!Number.isInteger(startHour) ||\n\t\t\t!Number.isInteger(endHour) ||\n\t\t\tstartHour < 0 ||\n\t\t\tendHour > 24 ||\n\t\t\tstartHour >= endHour ||\n\t\t\t!days.includes(local.weekday) ||\n\t\t\tlocal.hour < startHour ||\n\t\t\tlocal.hour >= endHour\n\t\t)\n\t\t\treasons.push('outside_calling_hours');\n\t\tif (kind === 'appointment' && !extra.inReminderWindow) reasons.push('not_in_reminder_window');\n\t\tif (kind === 'callback' && !extra.isInboundMiss)\n\t\t\treasons.push('not_a_recent_human_inbound_missed_call');\n\t\tif (kind === 'followup') {\n\t\t\tconst due = Date.parse(row.followUpAt ?? '');\n\t\t\tif (!Number.isFinite(due) || due > now.toMillis() || now.toMillis() - due > 86400000)\n\t\t\t\treasons.push('followup_not_due');\n\t\t\tif (String(row.stage ?? '') !== String(config.eligibleStage ?? 'follow_up'))\n\t\t\t\treasons.push('ineligible_crm_stage');\n\t\t}\n\t\tif (kind === 'invoice') {\n\t\t\tconst due = Date.parse(row.dueAt ?? '');\n\t\t\tconst daysToDue = (due - now.toMillis()) / 86400000;\n\t\t\tif (\n\t\t\t\trow.invoiceStatus !== 'open' ||\n\t\t\t\t!(Number(row.amountDue) > 0) ||\n\t\t\t\t!Number.isFinite(due) ||\n\t\t\t\tdaysToDue > 3 ||\n\t\t\t\tdaysToDue < -30 ||\n\t\t\t\tyes(row.disputed) ||\n\t\t\t\t!no(row.disputed)\n\t\t\t)\n\t\t\t\treasons.push('invoice_not_eligible');\n\t\t}\n\t\tif (kind === 'agent' && (!yes(row.approved) || !safeId(row.authorizationId)))\n\t\t\treasons.push('human_approval_required');\n\t\tif (['qualification', 'speed', 'booking', 'sheet'].includes(kind) && row.status !== 'ready')\n\t\t\treasons.push('record_not_ready');\n\t\t// A retry must retain the missed event's recipient-local day across midnight.\n\t\tconst eventMillis = Date.parse(sourceEvent?.occurredAt ?? '');\n\t\tconst day =\n\t\t\tkind === 'callback' && local.isValid && Number.isFinite(eventMillis)\n\t\t\t\t? local.minus({ milliseconds: now.toMillis() - eventMillis }).toISODate()\n\t\t\t\t: local.isValid\n\t\t\t\t\t? local.toISODate()\n\t\t\t\t\t: now.toISODate();\n\t\tconst identity =\n\t\t\tkind === 'callback'\n\t\t\t\t? phone + ':' + day\n\t\t\t\t: kind === 'agent'\n\t\t\t\t\t? row.authorizationId\n\t\t\t\t\t: row.recordId;\n\t\tconst callKey = 'ringee-' + kind + ':' + namespace + ':' + String(identity ?? '');\n\t\tif (callKey.length > 255) reasons.push('call_key_too_long');\n\t\tif (seen.has(phone)) reasons.push('duplicate_phone_in_input');\n\t\tif (!reasons.length && accepted >= limit) reasons.push('run_call_limit_reached');\n\t\tif (!reasons.length) {\n\t\t\taccepted++;\n\t\t\tseen.add(phone);\n\t\t}\n\t\treturn {\n\t\t\tjson: {\n\t\t\t\t...row,\n\t\t\t\t...extra,\n\t\t\t\t...(kind === 'callback' ? { missedEventOccurredAt: sourceEvent?.occurredAt ?? '' } : {}),\n\t\t\t\tphone,\n\t\t\t\tcallKey,\n\t\t\t\teligible: reasons.length === 0,\n\t\t\t\tdecision: reasons.length ? 'held' : 'eligible',\n\t\t\t\tholdReasons: reasons.join(', '),\n\t\t\t\ttemplate: kind,\n\t\t\t},\n\t\t\tpairedItem: { item: index },\n\t\t};\n\t});\n}\nreturn normalizeRecords($input.all(),$('Configuration').first().json,$now,\"sheet\",null);"
      },
      "id": "8e7ec23c-5812-4113-8ed3-5683d665c549",
      "name": "Normalize and check eligibility",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1280,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "7e239b23-f5a9-4e3b-876f-25dd4442204d",
              "leftValue": "={{ $json.eligible === true }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "eb20dddb-dbb2-4810-8f94-e4182cb8ffed",
      "name": "Eligible for one authorized call?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        1520,
        300
      ]
    },
    {
      "parameters": {
        "batchSize": 1,
        "options": {}
      },
      "id": "44986ca9-201d-4f48-8c33-61c2de24f7de",
      "name": "Process one record",
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        1760,
        300
      ]
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "function normalizeRecords(items, config, now, kind, sourceEvent = null) {\n\tconst yes = (v) => v === true || String(v).trim().toLowerCase() === 'true';\n\tconst no = (v) => v === false || String(v).trim().toLowerCase() === 'false';\n\tconst cleanPhone = (v) => {\n\t\tconst text = String(v ?? '').trim();\n\t\tif (!/^(?:\\+|00)[\\d\\s().-]+$/.test(text)) return '';\n\t\treturn text.replace(/^00/, '+').replace(/[\\s().-]/g, '');\n\t};\n\tconst safeId = (v) => /^[A-Za-z0-9_.:@/+~=-]{1,120}$/.test(String(v ?? ''));\n\tconst namespace = String(config.clientNamespace ?? '');\n\tconst limit = Math.max(1, Math.min(5, Math.floor(Number(config.maxCallsPerRun) || 1)));\n\tconst seen = new Set();\n\tlet accepted = 0;\n\treturn items.map((item, index) => {\n\t\tlet row = { ...(item.json.body ?? item.json) };\n\t\tlet extra = {};\n\t\tif (kind === 'appointment' && row.eventId) {\n\t\t\textra = {\n\t\t\t\teventId: row.eventId,\n\t\t\t\tappointmentStart: row.appointmentStart,\n\t\t\t\ttitle: row.title,\n\t\t\t\tinReminderWindow: Date.parse(row.appointmentStart ?? '') > now.toMillis(),\n\t\t\t};\n\t\t} else if (kind === 'appointment') {\n\t\t\tconst description = String(row.description ?? '');\n\t\t\tconst line = (key) =>\n\t\t\t\tdescription.match(new RegExp('^' + key + ':[ \\\\t]*([^\\\\r\\\\n]*)', 'im'))?.[1]?.trim() ?? '';\n\t\t\tconst startMillis = Date.parse(row.start?.dateTime ?? '');\n\t\t\tconst anchor = Date.parse(config.runStartedAt ?? '') || now.toMillis();\n\t\t\tconst minutes = (startMillis - anchor) / 60000;\n\t\t\textra = {\n\t\t\t\teventId: row.id,\n\t\t\t\tappointmentStart: row.start?.dateTime ?? '',\n\t\t\t\ttitle: row.summary ?? 'Appointment',\n\t\t\t\tinReminderWindow:\n\t\t\t\t\tNumber.isFinite(startMillis) &&\n\t\t\t\t\tminutes >= Number(config.reminderMinutes) &&\n\t\t\t\t\tminutes < Number(config.reminderMinutes) + 15 &&\n\t\t\t\t\trow.status !== 'cancelled',\n\t\t\t};\n\t\t\trow = {\n\t\t\t\trecordId: row.id,\n\t\t\t\tphone: line('Phone'),\n\t\t\t\tname: line('Name'),\n\t\t\t\ttimezone: line('Timezone'),\n\t\t\t\tconsent: line('Consent'),\n\t\t\t\tconsentRecordedAt: line('ConsentRecordedAt'),\n\t\t\t\tauthorized: line('Authorized'),\n\t\t\t\tsuppressionChecked: line('SuppressionChecked'),\n\t\t\t\tdoNotCall: line('DoNotCall'),\n\t\t\t\tattemptCount: line('AttemptCount'),\n\t\t\t\temail: line('Email'),\n\t\t\t};\n\t\t}\n\t\tif (kind === 'callback') {\n\t\t\tconst event = sourceEvent ?? {};\n\t\t\tconst data = event.data ?? {};\n\t\t\tconst timestamp = Date.parse(event.occurredAt ?? '');\n\t\t\tconst age = now.toMillis() - timestamp;\n\t\t\tconst isInboundMiss =\n\t\t\t\tevent.event === 'call.missed' &&\n\t\t\t\t(data.direction === 'inbound' || data.call?.direction === 'inbound') &&\n\t\t\t\t!data.agent &&\n\t\t\t\t!data.call?.voiceAgentCall &&\n\t\t\t\t!String(data.externalId ?? '').startsWith('ringee-callback:') &&\n\t\t\t\tage >= 0 &&\n\t\t\t\tage <= 30 * 60000;\n\t\t\textra = { eventId: event.eventId, missedCallId: data.callId, isInboundMiss };\n\t\t\trow = { ...row, recordId: data.callId, phone: data.fromNumber, name: row.name ?? 'Caller' };\n\t\t}\n\t\tconst phone = cleanPhone(row.phone);\n\t\tconst local = now.setZone(String(row.timezone ?? ''));\n\t\tconst reasons = [];\n\t\tif (!yes(config.callsEnabled)) reasons.push('calls_disabled');\n\t\tif (!/^[A-Za-z0-9_.-]{1,120}$/.test(namespace) || namespace.includes('CHANGE_ME'))\n\t\t\treasons.push('configure_client_namespace');\n\t\tif (!safeId(row.recordId)) reasons.push('missing_or_invalid_record_id');\n\t\tif (!/^\\+[1-9]\\d{7,14}$/.test(phone)) reasons.push('invalid_e164_phone');\n\t\tif (!yes(row.authorized) || !yes(row.consent)) reasons.push('authorization_or_consent_missing');\n\t\tconst consentAt = Date.parse(row.consentRecordedAt ?? '');\n\t\tif (!Number.isFinite(consentAt) || consentAt > now.toMillis())\n\t\t\treasons.push('invalid_consent_timestamp');\n\t\tif (!yes(row.suppressionChecked) || !no(row.doNotCall))\n\t\t\treasons.push('suppression_check_required');\n\t\tif (\n\t\t\t!(\n\t\t\t\trow.attemptCount === 0 ||\n\t\t\t\t(typeof row.attemptCount === 'string' && row.attemptCount.trim() === '0')\n\t\t\t)\n\t\t)\n\t\t\treasons.push('already_attempted_or_attempt_count_missing');\n\t\tconst startHour = Number(config.startHour);\n\t\tconst endHour = Number(config.endHour);\n\t\tconst days = String(config.callingDays ?? '')\n\t\t\t.split(',')\n\t\t\t.map(Number);\n\t\tif (!local.isValid || !String(row.timezone ?? '').includes('/'))\n\t\t\treasons.push('recipient_iana_timezone_required');\n\t\telse if (\n\t\t\t!Number.isInteger(startHour) ||\n\t\t\t!Number.isInteger(endHour) ||\n\t\t\tstartHour < 0 ||\n\t\t\tendHour > 24 ||\n\t\t\tstartHour >= endHour ||\n\t\t\t!days.includes(local.weekday) ||\n\t\t\tlocal.hour < startHour ||\n\t\t\tlocal.hour >= endHour\n\t\t)\n\t\t\treasons.push('outside_calling_hours');\n\t\tif (kind === 'appointment' && !extra.inReminderWindow) reasons.push('not_in_reminder_window');\n\t\tif (kind === 'callback' && !extra.isInboundMiss)\n\t\t\treasons.push('not_a_recent_human_inbound_missed_call');\n\t\tif (kind === 'followup') {\n\t\t\tconst due = Date.parse(row.followUpAt ?? '');\n\t\t\tif (!Number.isFinite(due) || due > now.toMillis() || now.toMillis() - due > 86400000)\n\t\t\t\treasons.push('followup_not_due');\n\t\t\tif (String(row.stage ?? '') !== String(config.eligibleStage ?? 'follow_up'))\n\t\t\t\treasons.push('ineligible_crm_stage');\n\t\t}\n\t\tif (kind === 'invoice') {\n\t\t\tconst due = Date.parse(row.dueAt ?? '');\n\t\t\tconst daysToDue = (due - now.toMillis()) / 86400000;\n\t\t\tif (\n\t\t\t\trow.invoiceStatus !== 'open' ||\n\t\t\t\t!(Number(row.amountDue) > 0) ||\n\t\t\t\t!Number.isFinite(due) ||\n\t\t\t\tdaysToDue > 3 ||\n\t\t\t\tdaysToDue < -30 ||\n\t\t\t\tyes(row.disputed) ||\n\t\t\t\t!no(row.disputed)\n\t\t\t)\n\t\t\t\treasons.push('invoice_not_eligible');\n\t\t}\n\t\tif (kind === 'agent' && (!yes(row.approved) || !safeId(row.authorizationId)))\n\t\t\treasons.push('human_approval_required');\n\t\tif (['qualification', 'speed', 'booking', 'sheet'].includes(kind) && row.status !== 'ready')\n\t\t\treasons.push('record_not_ready');\n\t\t// A retry must retain the missed event's recipient-local day across midnight.\n\t\tconst eventMillis = Date.parse(sourceEvent?.occurredAt ?? '');\n\t\tconst day =\n\t\t\tkind === 'callback' && local.isValid && Number.isFinite(eventMillis)\n\t\t\t\t? local.minus({ milliseconds: now.toMillis() - eventMillis }).toISODate()\n\t\t\t\t: local.isValid\n\t\t\t\t\t? local.toISODate()\n\t\t\t\t\t: now.toISODate();\n\t\tconst identity =\n\t\t\tkind === 'callback'\n\t\t\t\t? phone + ':' + day\n\t\t\t\t: kind === 'agent'\n\t\t\t\t\t? row.authorizationId\n\t\t\t\t\t: row.recordId;\n\t\tconst callKey = 'ringee-' + kind + ':' + namespace + ':' + String(identity ?? '');\n\t\tif (callKey.length > 255) reasons.push('call_key_too_long');\n\t\tif (seen.has(phone)) reasons.push('duplicate_phone_in_input');\n\t\tif (!reasons.length && accepted >= limit) reasons.push('run_call_limit_reached');\n\t\tif (!reasons.length) {\n\t\t\taccepted++;\n\t\t\tseen.add(phone);\n\t\t}\n\t\treturn {\n\t\t\tjson: {\n\t\t\t\t...row,\n\t\t\t\t...extra,\n\t\t\t\t...(kind === 'callback' ? { missedEventOccurredAt: sourceEvent?.occurredAt ?? '' } : {}),\n\t\t\t\tphone,\n\t\t\t\tcallKey,\n\t\t\t\teligible: reasons.length === 0,\n\t\t\t\tdecision: reasons.length ? 'held' : 'eligible',\n\t\t\t\tholdReasons: reasons.join(', '),\n\t\t\t\ttemplate: kind,\n\t\t\t},\n\t\t\tpairedItem: { item: index },\n\t\t};\n\t});\n}\nreturn normalizeRecords($input.all(),$('Configuration').first().json,$now,\"sheet\",null);"
      },
      "id": "1ca3fb07-0114-4a8b-8a86-23f2ccde59ec",
      "name": "Recheck hours before dialing",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        2000,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "b8979ec7-8453-42c1-82a3-09ec822f02c4",
              "leftValue": "={{ $json.eligible === true }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "cfcb0815-6dbb-450d-8d87-05522a9060dc",
      "name": "Still eligible now?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        2240,
        300
      ]
    },
    {
      "parameters": {
        "resource": "contact",
        "operation": "createOrUpdate",
        "phoneNumber": "={{ $('Recheck hours before dialing').item.json.phone }}",
        "additionalFields": {
          "name": "={{ $('Recheck hours before dialing').item.json.name }}",
          "email": "={{ $('Recheck hours before dialing').item.json.email || '' }}",
          "source": "n8n 11-controlled-sheet-calling"
        }
      },
      "id": "4765f08a-7d17-4955-8fd1-0edb07e4d099",
      "name": "Create or update Ringee contact",
      "type": "n8n-nodes-ringee.ringee",
      "typeVersion": 1,
      "position": [
        2480,
        300
      ],
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "resource": "aiAgent",
        "operation": "startCall",
        "agentId": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "phoneNumber": "={{ (function phoneAtDialTime(row, config, now) {\n\tconst local = now.setZone(String(row.timezone ?? ''));\n\tconst enabled = config.callsEnabled === true || config.callsEnabled === 'true';\n\tconst days = String(config.callingDays ?? '')\n\t\t.split(',')\n\t\t.map(Number);\n\tif (\n\t\t!enabled ||\n\t\trow.eligible !== true ||\n\t\t!local.isValid ||\n\t\t!days.includes(local.weekday) ||\n\t\tlocal.hour < Number(config.startHour) ||\n\t\tlocal.hour >= Number(config.endHour)\n\t) {\n\t\tthrow new Error(\n\t\t\t'The approved calling window is no longer open. Hold this record for manual review.',\n\t\t);\n\t}\n\tif (!/^\\+[1-9]\\d{7,14}$/.test(String(row.phone ?? '')))\n\t\tthrow new Error('A valid international phone number is required.');\n\tif (row.appointmentStart && Date.parse(row.appointmentStart) <= now.toMillis())\n\t\tthrow new Error('The appointment has already started.');\n\tif (row.template === 'callback') {\n\t\tconst age = now.toMillis() - Date.parse(row.missedEventOccurredAt ?? '');\n\t\tif (!Number.isFinite(age) || age < 0 || age > 30 * 60000)\n\t\t\tthrow new Error('The missed call is no longer recent. Hold for manual review.');\n\t}\n\treturn row.phone;\n})($('Recheck hours before dialing').item.json, $('Configuration').first().json, $now) }}",
        "variables": {
          "mappingMode": "defineBelow",
          "value": {
            "first_name": "={{ String($('Recheck hours before dialing').item.json.name || 'there').split(' ')[0] }}",
            "notification": "Please follow up on the authorized customer request."
          },
          "matchingColumns": [],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {
          "externalId": "={{ $('Recheck hours before dialing').item.json.callKey }}",
          "idempotencyKey": "={{ $('Recheck hours before dialing').item.json.callKey }}",
          "metadata": "={{ JSON.stringify({source_record_id:$('Recheck hours before dialing').item.json.recordId,template_slug:\"11-controlled-sheet-calling\"}) }}"
        }
      },
      "id": "25c825ef-05ae-4998-81ce-879dcfdbcbb0",
      "name": "Start authorized call",
      "type": "n8n-nodes-ringee.ringee",
      "typeVersion": 1,
      "position": [
        2720,
        300
      ],
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "return $input.all().map((item,index)=>({json:{...$('Recheck hours before dialing').item.json,...item.json},pairedItem:{item:index}}));"
      },
      "id": "1af12769-af06-4b00-8c93-70ff86affeb7",
      "name": "Remember accepted call",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        3480,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "18ea2a18-e48b-420f-8d02-dc22a867cad0",
              "leftValue": "={{ $json.queued === true }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "650506b6-d859-4ec9-862f-7d924f3f9f25",
      "name": "Was the call queued?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        3720,
        300
      ]
    },
    {
      "parameters": {
        "resource": "aiAgent",
        "operation": "cancelCall",
        "callId": "={{ $('Remember accepted call').item.json.call_id }}"
      },
      "id": "23346001-7ad3-427c-83be-53eae3ccb9b6",
      "name": "Withdraw queued call",
      "type": "n8n-nodes-ringee.ringee",
      "typeVersion": 1,
      "position": [
        3720,
        680
      ],
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "amount": 2,
        "unit": "minutes"
      },
      "id": "37ab4180-8a3b-4340-8414-652234ec7fa9",
      "name": "Wait for call completion",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        3960,
        300
      ],
      "webhookId": "ee6c53e7-4103-477d-8244-69455998e1b1"
    },
    {
      "parameters": {
        "resource": "aiAgent",
        "operation": "getCallResult",
        "callId": "={{ $('Remember accepted call').item.json.call_id }}"
      },
      "id": "72992705-09f9-4161-8c4d-51ce65549ae0",
      "name": "Read call result",
      "type": "n8n-nodes-ringee.ringee",
      "typeVersion": 1,
      "position": [
        4200,
        300
      ],
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "f660f769-0413-43dd-8bfe-5b68c6ecde06",
              "leftValue": "={{ $json.finished === true && (Boolean($json.outcome || $json.summary) || ['cancelled','expired','no_answer','busy','voicemail','failed'].includes($json.status)) }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "02cd1f9a-4986-4c0f-8b31-65837a2ba090",
      "name": "Final status and analysis?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        4440,
        300
      ]
    },
    {
      "parameters": {
        "amount": 5,
        "unit": "minutes"
      },
      "id": "6ea91db7-5fa8-48ba-8bbd-5f74b922d3b3",
      "name": "One final result wait",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        4440,
        680
      ],
      "webhookId": "ddc0aae9-e359-4232-87a7-f23d48e0f60c"
    },
    {
      "parameters": {
        "resource": "aiAgent",
        "operation": "getCallResult",
        "callId": "={{ $('Remember accepted call').item.json.call_id }}"
      },
      "id": "d691e58d-f4a1-4242-8c3f-bcc5669fcaa0",
      "name": "Read call result again",
      "type": "n8n-nodes-ringee.ringee",
      "typeVersion": 1,
      "position": [
        4680,
        680
      ],
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "function classifyResult(result, context, kind) {\n\tconst final = [\n\t\t'completed',\n\t\t'no_answer',\n\t\t'busy',\n\t\t'voicemail',\n\t\t'failed',\n\t\t'cancelled',\n\t\t'expired',\n\t].includes(result.status);\n\tconst analysisReady = final && Boolean(result.outcome || result.summary);\n\tlet route = 'needs_review';\n\tif (!final) route = 'pending_manual_review';\n\telse if (['cancelled', 'expired'].includes(result.status)) route = 'never_dialed';\n\telse if (['no_answer', 'busy', 'voicemail', 'failed'].includes(result.status))\n\t\troute = 'unreached';\n\telse if (!analysisReady) route = 'analysis_pending';\n\telse if (kind === 'appointment')\n\t\troute =\n\t\t\tresult.outcome === 'confirmed'\n\t\t\t\t? 'confirmed'\n\t\t\t\t: result.outcome === 'cannot_attend'\n\t\t\t\t\t? 'cancelled_by_customer'\n\t\t\t\t\t: 'follow_up';\n\telse if (['meeting_booked', 'appointment_booked'].includes(result.outcome)) route = 'sales_ready';\n\telse if (['callback_requested', 'callback_scheduled'].includes(result.outcome))\n\t\troute = 'follow_up';\n\telse if (['not_interested', 'wrong_number'].includes(result.outcome)) route = 'closed';\n\tif (kind === 'invoice' && final && analysisReady) route = 'staff_review';\n\treturn {\n\t\t...context,\n\t\tcall_id: result.call_id || context.call_id || '',\n\t\tstatus: result.status || 'unresolved',\n\t\toutcome: result.outcome ?? '',\n\t\tsummary: result.summary ?? '',\n\t\tsentiment: result.sentiment ?? '',\n\t\textracted_data: result.extracted_data ?? {},\n\t\tappointment: result.appointment ?? null,\n\t\tanalysisReady,\n\t\troute,\n\t\tneedsAttention: !['confirmed', 'sales_ready', 'closed'].includes(route),\n\t\tnotification:\n\t\t\t'Ringee ' +\n\t\t\tkind +\n\t\t\t': ' +\n\t\t\troute +\n\t\t\t'. Record ' +\n\t\t\tString(context.recordId ?? '') +\n\t\t\t'. Call ' +\n\t\t\tString(result.call_id || context.call_id || '') +\n\t\t\t'. Review the conversation in Ringee.',\n\t};\n}\nreturn $input.all().map((item,index)=>({json:classifyResult(item.json,$('Remember accepted call').item.json,\"sheet\"),pairedItem:{item:index}}));"
      },
      "id": "02f7deaf-f181-4126-8000-bf9877708b44",
      "name": "Business result",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        4940,
        300
      ]
    },
    {
      "parameters": {
        "resource": "sheet",
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "sheetName": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "options": {
          "cellFormat": "RAW",
          "useAppend": true
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "recordId": "={{ $('Business result').item.json.recordId }}",
            "callKey": "={{ $('Business result').item.json.callKey }}",
            "call_id": "={{ $('Business result').item.json.call_id }}",
            "status": "={{ $('Business result').item.json.status }}",
            "outcome": "={{ $('Business result').item.json.outcome }}",
            "summary": "={{ $('Business result').item.json.summary }}",
            "sentiment": "={{ $('Business result').item.json.sentiment }}",
            "route": "={{ $('Business result').item.json.route }}",
            "attemptCount": 1
          },
          "matchingColumns": [
            "recordId"
          ],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "id": "b58654a4-c015-4d33-8713-798f37a75432",
      "name": "Save actual call result",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        5180,
        300
      ],
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "resource": "message",
        "operation": "post",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "text": "={{ $('Business result').item.json.notification }}",
        "otherOptions": {
          "includeLinkToWorkflow": false
        }
      },
      "id": "6c0069ae-703b-4772-82aa-ce70022db7b2",
      "name": "Notify the responsible team",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.7,
      "position": [
        6900,
        300
      ],
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "amount": 2,
        "unit": "seconds"
      },
      "id": "faf3d19e-b07a-4eb7-8b8f-3b269543824f",
      "name": "Pace the next record",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        7140,
        300
      ],
      "webhookId": "0734c041-5f04-4e6f-8e57-37960fba2ac7"
    },
    {
      "parameters": {
        "content": "## Reconcile accepted work\nWithdraw a queued call before it drifts outside the calling window. Read delayed results with the existing call ID. Neither branch starts another call.",
        "width": 1500,
        "height": 370,
        "color": 7
      },
      "id": "c9db5e8b-04c4-429d-8f8d-1bb4973cad67",
      "name": "Queued and delayed results",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        3440,
        600
      ]
    },
    {
      "id": "77151756-b8b2-4c8f-8e03-b30489c6b584",
      "name": "Hold this record and continue",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        520,
        2200
      ],
      "parameters": {}
    },
    {
      "id": "731b6a2f-6c2a-4784-8391-c0146bb9df3f",
      "name": "Reconcile failed withdrawal",
      "type": "n8n-nodes-ringee.ringee",
      "typeVersion": 1,
      "position": [
        920,
        2200
      ],
      "parameters": {
        "resource": "aiAgent",
        "operation": "getCallStatus",
        "callId": "={{ $('Remember accepted call').item.json.call_id }}"
      },
      "onError": "continueErrorOutput"
    },
    {
      "id": "207b35ab-92dc-4c70-8ed9-77886447afeb",
      "name": "Require resolved withdrawal",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1320,
        2200
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const row=$input.first().json; if (!row.status || row.status==='queued') throw new Error('Withdrawal is unconfirmed and the original call can still dispatch. Reconcile its call ID immediately; never start another call.'); return $input.all();"
      }
    },
    {
      "id": "43bfc03a-c1c4-41eb-87ab-3e83eaf37efa",
      "name": "Read Ringee queue policy",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.5,
      "position": [
        1720,
        2200
      ],
      "parameters": {
        "method": "GET",
        "url": "https://api.ringee.io/api/v1/capabilities",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "ringeeApi",
        "options": {
          "redirect": {
            "redirect": {
              "followRedirects": false
            }
          },
          "timeout": 10000
        }
      },
      "onError": "continueErrorOutput"
    },
    {
      "id": "a99967fb-412d-47d4-8eb4-fd1977f39135",
      "name": "Require immediate dispatch support",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        2120,
        2200
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const c=$input.first().json; if(c.apiVersion!==1 || c.capabilities?.idempotentCalls!==true || c.capabilities?.queuedCalls!==false) throw new Error('This calling template requires a queue-disabled Ringee Cloud deployment. The published node cannot enforce a recipient-window dispatch deadline. No call was submitted.'); return [{json:$('Recheck hours before dialing').item.json}];"
      }
    },
    {
      "id": "b2626b8a-d6a7-4fff-8ced-4f1d665952ea",
      "name": "Refresh approved source row",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        520,
        2480
      ],
      "parameters": {
        "resource": "sheet",
        "operation": "read",
        "documentId": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "sheetName": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupColumn": "recordId",
              "lookupValue": "={{ $('Process one record').item.json.recordId }}"
            }
          ]
        }
      },
      "alwaysOutputData": true,
      "onError": "continueErrorOutput"
    },
    {
      "id": "4cf4bc5e-4138-4dcc-8255-b3c11977b051",
      "name": "Require one current source row",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        920,
        2480
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const rows=$input.all(); const id=$('Process one record').item.json.recordId; if(rows.length!==1 || String(rows[0].json.recordId)!==String(id)) return [{json:{recordId:id,eligible:false,holdReasons:'source_row_missing_or_ambiguous'}}]; return rows;"
      }
    }
  ],
  "connections": {
    "Run approved queue": {
      "main": [
        [
          {
            "node": "Configuration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read approved source rows": {
      "main": [
        [
          {
            "node": "Normalize and check eligibility",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Failure requires reconciliation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Configuration": {
      "main": [
        [
          {
            "node": "Read approved source rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize and check eligibility": {
      "main": [
        [
          {
            "node": "Eligible for one authorized call?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Eligible for one authorized call?": {
      "main": [
        [
          {
            "node": "Process one record",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Held for manual review",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process one record": {
      "main": [
        [],
        [
          {
            "node": "Refresh approved source row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Recheck hours before dialing": {
      "main": [
        [
          {
            "node": "Still eligible now?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Still eligible now?": {
      "main": [
        [
          {
            "node": "Read Ringee queue policy",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Hold this record and continue",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create or update Ringee contact": {
      "main": [
        [
          {
            "node": "Start authorized call",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Failure requires reconciliation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Start authorized call": {
      "main": [
        [
          {
            "node": "Remember accepted call",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Failure requires reconciliation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Remember accepted call": {
      "main": [
        [
          {
            "node": "Was the call queued?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Withdraw queued call": {
      "main": [
        [
          {
            "node": "Wait for call completion",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Reconcile failed withdrawal",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Was the call queued?": {
      "main": [
        [
          {
            "node": "Withdraw queued call",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait for call completion",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read call result": {
      "main": [
        [
          {
            "node": "Final status and analysis?",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "One final result wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait for call completion": {
      "main": [
        [
          {
            "node": "Read call result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Final status and analysis?": {
      "main": [
        [
          {
            "node": "Business result",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "One final result wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read call result again": {
      "main": [
        [
          {
            "node": "Business result",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Failure requires reconciliation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "One final result wait": {
      "main": [
        [
          {
            "node": "Read call result again",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save actual call result": {
      "main": [
        [
          {
            "node": "Notify the responsible team",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Failure requires reconciliation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Business result": {
      "main": [
        [
          {
            "node": "Save actual call result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notify the responsible team": {
      "main": [
        [
          {
            "node": "Pace the next record",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Failure requires reconciliation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pace the next record": {
      "main": [
        [
          {
            "node": "Process one record",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Hold this record and continue": {
      "main": [
        [
          {
            "node": "Process one record",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reconcile failed withdrawal": {
      "main": [
        [
          {
            "node": "Require resolved withdrawal",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Failure requires reconciliation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Require resolved withdrawal": {
      "main": [
        [
          {
            "node": "Wait for call completion",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Ringee queue policy": {
      "main": [
        [
          {
            "node": "Require immediate dispatch support",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Failure requires reconciliation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Require immediate dispatch support": {
      "main": [
        [
          {
            "node": "Create or update Ringee contact",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Refresh approved source row": {
      "main": [
        [
          {
            "node": "Require one current source row",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Failure requires reconciliation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Require one current source row": {
      "main": [
        [
          {
            "node": "Recheck hours before dialing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "executionTimeout": 3600
  },
  "pinData": {},
  "tags": []
}
