“Can’t determine which item to use” when fetching call details after Split In Batches

I’m building an outbound calling workflow using Split In Batches with a batch size of 10.

  • Step 1: Split In Batches → creates 10 calls at once

  • Step 2: Wait node → 20 seconds

  • Step 3: Fetch Call Details → checks the status of each call

  • Step 4: When all 10 calls are ended, the next batch should process

The issue: In the Fetch Call Details node I get this error: Can’t determine which item to use

Expected behavior

I want the Fetch Call Details node to correctly loop through each of the 10 calls, check their status, and only proceed when all are "ended".

Hi @Muhammad_Hamza_Azhar,

As per the error you need to use “.first()” instead of “.item”

When using .first(), does n8n resolve .first() based on the actual order of call completions, or is it just the first item from the previous node’s output array?

Oh wait you’re using the Loop node in batches of 10?

Please can you share your workflow in a code block and pin any test data I can use to run it on my side.

Also please specifiy whether you are on version 1 or 2 of n8n

I am using version 1.

Please share again as something looks corrupted with what you shared

Is this okay?

> {
  "name": "EO Consult copy",
  "nodes": [
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "1bsB_56U31fb0jhOLPXo1z-xzSRl3Ny4bRhkKwAvZsPc",
          "mode": "list",
          "cachedResultName": "EO Consult - Customers",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1bsB_56U31fb0jhOLPXo1z-xzSRl3Ny4bRhkKwAvZsPc/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": 688905639,
          "mode": "list",
          "cachedResultName": "accorex-ai-agent-1286",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1bsB_56U31fb0jhOLPXo1z-xzSRl3Ny4bRhkKwAvZsPc/edit#gid=688905639"
        },
        "options": {
          "dataLocationOnSheet": {
            "values": {
              "rangeDefinition": "specifyRangeA1",
              "range": "1:20"
            }
          }
        }
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        -992,
        3936
      ],
      "id": "1226130f-8099-4008-806d-c600b03f5664",
      "name": "Get Leads",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "BJeBRkILZNNQmHXA",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.vapi.ai/call",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"assistantId\": \"12882088-6821-4e66-8acb-e35cb1b9a24f\",\n  \"phoneNumberId\": \"7a07dd74-fc42-45fb-9b64-33a7390beae9\",\n  \"customer\": {\n    \"number\": \"{{ $('Loop Over Items - Batch Size 10').item.json.phone }}\"\n  },\n  \"assistantOverrides\": {\n    \"variableValues\": {\n      \"fname\": \"{{ $('Loop Over Items - Batch Size 10').item.json.fname }}\",\n      \"lname\": \"{{ $('Loop Over Items - Batch Size 10').item.json.lname }}\",\n      \"email\": \"{{ $('Loop Over Items - Batch Size 10').item.json.email }}\"\n    }\n  }\n}\n",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.3,
      "position": [
        -544,
        3856
      ],
      "id": "74bbe800-6e2e-4d5b-abe9-ced7a353e026",
      "name": "Create Call - Vapi",
      "credentials": {
        "httpBearerAuth": {
          "id": "Xz94fTp8fSHA90Zp",
          "name": "VAPI"
        }
      }
    },
    {
      "parameters": {
        "url": "=https://api.vapi.ai/call/{{ $('Create Call - Vapi').first().json.id }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.3,
      "position": [
        -96,
        3792
      ],
      "id": "b0a074f2-c804-471d-b8f8-4fa28c44b029",
      "name": "Fetch Call Details - Vapi",
      "credentials": {
        "httpBearerAuth": {
          "id": "Xz94fTp8fSHA90Zp",
          "name": "VAPI"
        }
      }
    },
    {
      "parameters": {
        "amount": 10
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        -320,
        3856
      ],
      "id": "ebe224e1-0306-41b3-a6c3-176403fdbf6a",
      "name": "Wait 20 sec",
      "webhookId": "f82d3bd6-16f6-4d9f-8299-137fc2ee5d9d"
    },
    {
      "parameters": {
        "jsCode": "const items = $input.all();\nconst allEnded = items.every(item => item.json.status === \"ended\");\n\nreturn [\n  {\n    json: {\n      allEnded: allEnded\n    }\n  }\n];\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        128,
        3792
      ],
      "id": "4c698e65-b907-4ab4-af6a-656d67571e48",
      "name": "Check For Call Status"
    },
    {
      "parameters": {
        "batchSize": 10,
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        -768,
        3936
      ],
      "id": "74148fd5-3f56-42ca-9dc5-a5315ee5bb49",
      "name": "Loop Over Items - Batch Size 10"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "82fdfc5e-d589-4e07-8163-649037268df4",
              "leftValue": "={{ $json.allEnded }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        352,
        3936
      ],
      "id": "95008761-7d5a-469b-947a-db6e7ae6b817",
      "name": "Check If All 10 Calls are Ended"
    }
  ],
  "pinData": {
    "Create Call - Vapi": [
      {
        "json": {
          "subscriptionLimits": {
            "concurrencyBlocked": false,
            "concurrencyLimit": 10,
            "remainingConcurrentCalls": 9
          },
          "id": "019ba729-2870-7662-804d-25882cc632e0",
          "assistantId": "12882088-6821-4e66-8acb-e35cb1b9a24f",
          "phoneNumberId": "7a07dd74-fc42-45fb-9b64-33a7390beae9",
          "type": "outboundPhoneCall",
          "createdAt": "2026-01-10T09:07:31.056Z",
          "updatedAt": "2026-01-10T09:07:31.056Z",
          "orgId": "aefb127c-6ec8-4840-b2b4-3f9922d625ed",
          "cost": 0,
          "customer": {
            "number": "+447919543532"
          },
          "status": "queued",
          "phoneCallProvider": "twilio",
          "assistantOverrides": {
            "variableValues": {
              "email": "[email protected]",
              "fname": "Martin",
              "lname": "Potter"
            }
          },
          "monitor": {
            "listenUrl": "wss://phone-call-websocket.aws-us-west-2-backend-production2.vapi.ai/019ba729-2870-7662-804d-25882cc632e0/listen",
            "controlUrl": "https://phone-call-websocket.aws-us-west-2-backend-production2.vapi.ai/019ba729-2870-7662-804d-25882cc632e0/control"
          },
          "transport": {
            "conversationType": "voice",
            "provider": "twilio",
            "accountSid": "AC1ffb1234a036f9aea83775a8a90fcd43"
          }
        }
      },
      {
        "json": {
          "subscriptionLimits": {
            "concurrencyBlocked": false,
            "concurrencyLimit": 10,
            "remainingConcurrentCalls": 9
          },
          "id": "019ba729-2899-7aa4-a7ae-e965b524f1a2",
          "assistantId": "12882088-6821-4e66-8acb-e35cb1b9a24f",
          "phoneNumberId": "7a07dd74-fc42-45fb-9b64-33a7390beae9",
          "type": "outboundPhoneCall",
          "createdAt": "2026-01-10T09:07:31.097Z",
          "updatedAt": "2026-01-10T09:07:31.097Z",
          "orgId": "aefb127c-6ec8-4840-b2b4-3f9922d625ed",
          "cost": 0,
          "customer": {
            "number": "+447877711925"
          },
          "status": "queued",
          "phoneCallProvider": "twilio",
          "assistantOverrides": {
            "variableValues": {
              "email": "[email protected]",
              "fname": "Chris",
              "lname": "Knowles"
            }
          },
          "monitor": {
            "listenUrl": "wss://phone-call-websocket.aws-us-west-2-backend-production2.vapi.ai/019ba729-2899-7aa4-a7ae-e965b524f1a2/listen",
            "controlUrl": "https://phone-call-websocket.aws-us-west-2-backend-production2.vapi.ai/019ba729-2899-7aa4-a7ae-e965b524f1a2/control"
          },
          "transport": {
            "conversationType": "voice",
            "provider": "twilio",
            "accountSid": "AC1ffb1234a036f9aea83775a8a90fcd43"
          }
        }
      },
      {
        "json": {
          "subscriptionLimits": {
            "concurrencyBlocked": false,
            "concurrencyLimit": 10,
            "remainingConcurrentCalls": 9
          },
          "id": "019ba729-2871-7fff-bc2a-548f399f0954",
          "assistantId": "12882088-6821-4e66-8acb-e35cb1b9a24f",
          "phoneNumberId": "7a07dd74-fc42-45fb-9b64-33a7390beae9",
          "type": "outboundPhoneCall",
          "createdAt": "2026-01-10T09:07:31.057Z",
          "updatedAt": "2026-01-10T09:07:31.057Z",
          "orgId": "aefb127c-6ec8-4840-b2b4-3f9922d625ed",
          "cost": 0,
          "customer": {
            "number": "+447479676078"
          },
          "status": "queued",
          "phoneCallProvider": "twilio",
          "assistantOverrides": {
            "variableValues": {
              "email": "[email protected]",
              "fname": "PETER",
              "lname": "MUNETSI"
            }
          },
          "monitor": {
            "listenUrl": "wss://phone-call-websocket.aws-us-west-2-backend-production2.vapi.ai/019ba729-2871-7fff-bc2a-548f399f0954/listen",
            "controlUrl": "https://phone-call-websocket.aws-us-west-2-backend-production2.vapi.ai/019ba729-2871-7fff-bc2a-548f399f0954/control"
          },
          "transport": {
            "conversationType": "voice",
            "provider": "twilio",
            "accountSid": "AC1ffb1234a036f9aea83775a8a90fcd43"
          }
        }
      },
      {
        "json": {
          "subscriptionLimits": {
            "concurrencyBlocked": false,
            "concurrencyLimit": 10,
            "remainingConcurrentCalls": 9
          },
          "id": "019ba729-2880-7eeb-ab84-fa7873ada92a",
          "assistantId": "12882088-6821-4e66-8acb-e35cb1b9a24f",
          "phoneNumberId": "7a07dd74-fc42-45fb-9b64-33a7390beae9",
          "type": "outboundPhoneCall",
          "createdAt": "2026-01-10T09:07:31.072Z",
          "updatedAt": "2026-01-10T09:07:31.072Z",
          "orgId": "aefb127c-6ec8-4840-b2b4-3f9922d625ed",
          "cost": 0,
          "customer": {
            "number": "+447795494660"
          },
          "status": "queued",
          "phoneCallProvider": "twilio",
          "assistantOverrides": {
            "variableValues": {
              "email": "[email protected]",
              "fname": "Neil",
              "lname": "Douglas"
            }
          },
          "monitor": {
            "listenUrl": "wss://phone-call-websocket.aws-us-west-2-backend-production2.vapi.ai/019ba729-2880-7eeb-ab84-fa7873ada92a/listen",
            "controlUrl": "https://phone-call-websocket.aws-us-west-2-backend-production2.vapi.ai/019ba729-2880-7eeb-ab84-fa7873ada92a/control"
          },
          "transport": {
            "conversationType": "voice",
            "provider": "twilio",
            "accountSid": "AC1ffb1234a036f9aea83775a8a90fcd43"
          }
        }
      },
      {
        "json": {
          "subscriptionLimits": {
            "concurrencyBlocked": false,
            "concurrencyLimit": 10,
            "remainingConcurrentCalls": 9
          },
          "id": "019ba729-2892-700f-8968-6db1a77efc04",
          "assistantId": "12882088-6821-4e66-8acb-e35cb1b9a24f",
          "phoneNumberId": "7a07dd74-fc42-45fb-9b64-33a7390beae9",
          "type": "outboundPhoneCall",
          "createdAt": "2026-01-10T09:07:31.090Z",
          "updatedAt": "2026-01-10T09:07:31.090Z",
          "orgId": "aefb127c-6ec8-4840-b2b4-3f9922d625ed",
          "cost": 0,
          "customer": {
            "number": "+447787571337"
          },
          "status": "queued",
          "phoneCallProvider": "twilio",
          "assistantOverrides": {
            "variableValues": {
              "email": "[email protected]",
              "fname": "Mabel",
              "lname": "Casyao"
            }
          },
          "monitor": {
            "listenUrl": "wss://phone-call-websocket.aws-us-west-2-backend-production2.vapi.ai/019ba729-2892-700f-8968-6db1a77efc04/listen",
            "controlUrl": "https://phone-call-websocket.aws-us-west-2-backend-production2.vapi.ai/019ba729-2892-700f-8968-6db1a77efc04/control"
          },
          "transport": {
            "conversationType": "voice",
            "provider": "twilio",
            "accountSid": "AC1ffb1234a036f9aea83775a8a90fcd43"
          }
        }
      },
      {
        "json": {
          "subscriptionLimits": {
            "concurrencyBlocked": false,
            "concurrencyLimit": 10,
            "remainingConcurrentCalls": 7
          },
          "id": "019ba729-28a7-7667-8663-e849f702d7ee",
          "assistantId": "12882088-6821-4e66-8acb-e35cb1b9a24f",
          "phoneNumberId": "7a07dd74-fc42-45fb-9b64-33a7390beae9",
          "type": "outboundPhoneCall",
          "createdAt": "2026-01-10T09:07:31.111Z",
          "updatedAt": "2026-01-10T09:07:31.111Z",
          "orgId": "aefb127c-6ec8-4840-b2b4-3f9922d625ed",
          "cost": 0,
          "customer": {
            "number": "+447842749534"
          },
          "status": "queued",
          "phoneCallProvider": "twilio",
          "assistantOverrides": {
            "variableValues": {
              "email": "[email protected]",
              "fname": "Martin",
              "lname": "Smith"
            }
          },
          "monitor": {
            "listenUrl": "wss://phone-call-websocket.aws-us-west-2-backend-production2.vapi.ai/019ba729-28a7-7667-8663-e849f702d7ee/listen",
            "controlUrl": "https://phone-call-websocket.aws-us-west-2-backend-production2.vapi.ai/019ba729-28a7-7667-8663-e849f702d7ee/control"
          },
          "transport": {
            "conversationType": "voice",
            "provider": "twilio",
            "accountSid": "AC1ffb1234a036f9aea83775a8a90fcd43"
          }
        }
      },
      {
        "json": {
          "subscriptionLimits": {
            "concurrencyBlocked": false,
            "concurrencyLimit": 10,
            "remainingConcurrentCalls": 4
          },
          "id": "019ba729-28c8-7eeb-ab85-07d2fff2bdbc",
          "assistantId": "12882088-6821-4e66-8acb-e35cb1b9a24f",
          "phoneNumberId": "7a07dd74-fc42-45fb-9b64-33a7390beae9",
          "type": "outboundPhoneCall",
          "createdAt": "2026-01-10T09:07:31.144Z",
          "updatedAt": "2026-01-10T09:07:31.144Z",
          "orgId": "aefb127c-6ec8-4840-b2b4-3f9922d625ed",
          "cost": 0,
          "customer": {
            "number": "+447905318813"
          },
          "status": "queued",
          "phoneCallProvider": "twilio",
          "assistantOverrides": {
            "variableValues": {
              "email": "[email protected]",
              "fname": "Onyekachi",
              "lname": "Onyema"
            }
          },
          "monitor": {
            "listenUrl": "wss://phone-call-websocket.aws-us-west-2-backend-production2.vapi.ai/019ba729-28c8-7eeb-ab85-07d2fff2bdbc/listen",
            "controlUrl": "https://phone-call-websocket.aws-us-west-2-backend-production2.vapi.ai/019ba729-28c8-7eeb-ab85-07d2fff2bdbc/control"
          },
          "transport": {
            "conversationType": "voice",
            "provider": "twilio",
            "accountSid": "AC1ffb1234a036f9aea83775a8a90fcd43"
          }
        }
      },
      {
        "json": {
          "subscriptionLimits": {
            "concurrencyBlocked": false,
            "concurrencyLimit": 10,
            "remainingConcurrentCalls": 4
          },
          "id": "019ba729-28e9-7ff9-97ee-1a2f7ae57e8c",
          "assistantId": "12882088-6821-4e66-8acb-e35cb1b9a24f",
          "phoneNumberId": "7a07dd74-fc42-45fb-9b64-33a7390beae9",
          "type": "outboundPhoneCall",
          "createdAt": "2026-01-10T09:07:31.177Z",
          "updatedAt": "2026-01-10T09:07:31.177Z",
          "orgId": "aefb127c-6ec8-4840-b2b4-3f9922d625ed",
          "cost": 0,
          "customer": {
            "number": "+447751576293"
          },
          "status": "queued",
          "phoneCallProvider": "twilio",
          "assistantOverrides": {
            "variableValues": {
              "email": "[email protected]",
              "fname": "Alessandro",
              "lname": "Papa"
            }
          },
          "monitor": {
            "listenUrl": "wss://phone-call-websocket.aws-us-west-2-backend-production2.vapi.ai/019ba729-28e9-7ff9-97ee-1a2f7ae57e8c/listen",
            "controlUrl": "https://phone-call-websocket.aws-us-west-2-backend-production2.vapi.ai/019ba729-28e9-7ff9-97ee-1a2f7ae57e8c/control"
          },
          "transport": {
            "conversationType": "voice",
            "provider": "twilio",
            "accountSid": "AC1ffb1234a036f9aea83775a8a90fcd43"
          }
        }
      },
      {
        "json": {
          "subscriptionLimits": {
            "concurrencyBlocked": false,
            "concurrencyLimit": 10,
            "remainingConcurrentCalls": 4
          },
          "id": "019ba729-28e2-7aa4-a7ae-f5afdced5a47",
          "assistantId": "12882088-6821-4e66-8acb-e35cb1b9a24f",
          "phoneNumberId": "7a07dd74-fc42-45fb-9b64-33a7390beae9",
          "type": "outboundPhoneCall",
          "createdAt": "2026-01-10T09:07:31.170Z",
          "updatedAt": "2026-01-10T09:07:31.170Z",
          "orgId": "aefb127c-6ec8-4840-b2b4-3f9922d625ed",
          "cost": 0,
          "customer": {
            "number": "+447411761110"
          },
          "status": "queued",
          "phoneCallProvider": "twilio",
          "assistantOverrides": {
            "variableValues": {
              "email": "[email protected]",
              "fname": "Deloise",
              "lname": "Abbeyquaye"
            }
          },
          "monitor": {
            "listenUrl": "wss://phone-call-websocket.aws-us-west-2-backend-production2.vapi.ai/019ba729-28e2-7aa4-a7ae-f5afdced5a47/listen",
            "controlUrl": "https://phone-call-websocket.aws-us-west-2-backend-production2.vapi.ai/019ba729-28e2-7aa4-a7ae-f5afdced5a47/control"
          },
          "transport": {
            "conversationType": "voice",
            "provider": "twilio",
            "accountSid": "AC1ffb1234a036f9aea83775a8a90fcd43"
          }
        }
      },
      {
        "json": {
          "subscriptionLimits": {
            "concurrencyBlocked": false,
            "concurrencyLimit": 10,
            "remainingConcurrentCalls": 3
          },
          "id": "019ba729-2902-7eeb-ab85-0f3aca088209",
          "assistantId": "12882088-6821-4e66-8acb-e35cb1b9a24f",
          "phoneNumberId": "7a07dd74-fc42-45fb-9b64-33a7390beae9",
          "type": "outboundPhoneCall",
          "createdAt": "2026-01-10T09:07:31.202Z",
          "updatedAt": "2026-01-10T09:07:31.202Z",
          "orgId": "aefb127c-6ec8-4840-b2b4-3f9922d625ed",
          "cost": 0,
          "customer": {
            "number": "+447985588206"
          },
          "status": "queued",
          "phoneCallProvider": "twilio",
          "assistantOverrides": {
            "variableValues": {
              "email": "[email protected]",
              "fname": "Rahel",
              "lname": "Abegas"
            }
          },
          "monitor": {
            "listenUrl": "wss://phone-call-websocket.aws-us-west-2-backend-production2.vapi.ai/019ba729-2902-7eeb-ab85-0f3aca088209/listen",
            "controlUrl": "https://phone-call-websocket.aws-us-west-2-backend-production2.vapi.ai/019ba729-2902-7eeb-ab85-0f3aca088209/control"
          },
          "transport": {
            "conversationType": "voice",
            "provider": "twilio",
            "accountSid": "AC1ffb1234a036f9aea83775a8a90fcd43"
          }
        }
      }
    ],
    "Get Leads": [
      {
        "json": {
          "row_number": 2,
          "fname": "Martin",
          "lname": "Potter",
          "email": "[email protected]",
          "phone": "+447919543532",
          "country": "GB",
          "source": "LT_Depo"
        }
      },
      {
        "json": {
          "row_number": 3,
          "fname": "Chris",
          "lname": "Knowles",
          "email": "[email protected]",
          "phone": "+447877711925",
          "country": "GB",
          "source": "LT_Depo"
        }
      },
      {
        "json": {
          "row_number": 4,
          "fname": "PETER",
          "lname": "MUNETSI",
          "email": "[email protected]",
          "phone": "+447479676078",
          "country": "GB",
          "source": "LT_Depo"
        }
      },
      {
        "json": {
          "row_number": 5,
          "fname": "Neil",
          "lname": "Douglas",
          "email": "[email protected]",
          "phone": "+447795494660",
          "country": "GB",
          "source": "LT_Depo"
        }
      },
      {
        "json": {
          "row_number": 6,
          "fname": "Mabel",
          "lname": "Casyao",
          "email": "[email protected]",
          "phone": "+447787571337",
          "country": "GB",
          "source": "LT_Depo"
        }
      },
      {
        "json": {
          "row_number": 7,
          "fname": "Martin",
          "lname": "Smith",
          "email": "[email protected]",
          "phone": "+447842749534",
          "country": "GB",
          "source": "LT_Depo"
        }
      },
      {
        "json": {
          "row_number": 8,
          "fname": "Onyekachi",
          "lname": "Onyema",
          "email": "[email protected]",
          "phone": "+447905318813",
          "country": "GB",
          "source": "LT_Depo"
        }
      },
      {
        "json": {
          "row_number": 9,
          "fname": "Alessandro",
          "lname": "Papa",
          "email": "[email protected]",
          "phone": "+447751576293",
          "country": "GB",
          "source": "LT_Depo"
        }
      },
      {
        "json": {
          "row_number": 10,
          "fname": "Deloise",
          "lname": "Abbeyquaye",
          "email": "[email protected]",
          "phone": "+447411761110",
          "country": "GB",
          "source": "LT_Depo"
        }
      },
      {
        "json": {
          "row_number": 11,
          "fname": "Rahel",
          "lname": "Abegas",
          "email": "[email protected]",
          "phone": "+447985588206",
          "country": "GB",
          "source": "LT_Depo"
        }
      },
      {
        "json": {
          "row_number": 12,
          "fname": "Andre",
          "lname": "Brooks",
          "email": "[email protected]",
          "phone": "+447875203403",
          "country": "GB",
          "source": "LT_Depo"
        }
      },
      {
        "json": {
          "row_number": 13,
          "fname": "Manuel",
          "lname": "Mendes",
          "email": "[email protected]",
          "phone": "+447552374995",
          "country": "GB",
          "source": "LT_Depo"
        }
      },
      {
        "json": {
          "row_number": 14,
          "fname": "Wendy",
          "lname": "Fitzpatrick",
          "email": "[email protected]",
          "phone": "+447484787050",
          "country": "GB",
          "source": "LT_Depo"
        }
      },
      {
        "json": {
          "row_number": 15,
          "fname": "Kehinde",
          "lname": "Ahmedjohnson",
          "email": "[email protected]",
          "phone": "+447497765851",
          "country": "GB",
          "source": "LT_Depo"
        }
      },
      {
        "json": {
          "row_number": 16,
          "fname": "Hadine",
          "lname": "Hibbert",
          "email": "[email protected]",
          "phone": "+447944217240",
          "country": "GB",
          "source": "LT_Depo"
        }
      },
      {
        "json": {
          "row_number": 17,
          "fname": "Nigel",
          "lname": "Cave",
          "email": "[email protected]",
          "phone": "+441252404585",
          "country": "GB",
          "source": "LT_Depo"
        }
      },
      {
        "json": {
          "row_number": 18,
          "fname": "GERALDINE",
          "lname": "ODIGIE",
          "email": "[email protected]",
          "phone": "+447401126212",
          "country": "GB",
          "source": "LT_Depo"
        }
      },
      {
        "json": {
          "row_number": 19,
          "fname": "sabrina",
          "lname": "roachford",
          "email": "[email protected]",
          "phone": "+447956527506",
          "country": "GB",
          "source": "LT_Depo"
        }
      },
      {
        "json": {
          "row_number": 20,
          "fname": "Willie",
          "lname": "Mcilear",
          "email": "[email protected]",
          "phone": "+447881625654",
          "country": "GB",
          "source": "LT_Depo"
        }
      }
    ]
  },
  "connections": {
    "Get Leads": {
      "main": [
        [
          {
            "node": "Loop Over Items - Batch Size 10",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Call - Vapi": {
      "main": [
        [
          {
            "node": "Wait 20 sec",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 20 sec": {
      "main": [
        [
          {
            "node": "Fetch Call Details - Vapi",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Call Details - Vapi": {
      "main": [
        [
          {
            "node": "Check For Call Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check For Call Status": {
      "main": [
        [
          {
            "node": "Check If All 10 Calls are Ended",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items - Batch Size 10": {
      "main": [
        [],
        [
          {
            "node": "Create Call - Vapi",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check If All 10 Calls are Ended": {
      "main": [
        [
          {
            "node": "Loop Over Items - Batch Size 10",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait 20 sec",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "timezone": "Europe/Berlin",
    "callerPolicy": "workflowsFromSameOwner",
    "availableInMCP": false
  },
  "versionId": "eb08f79d-633a-407b-9f57-9f6cf21f3092",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "60511225625cdbb13e2ab9af5c99a7df8b5976456d6885dced7ccd1edd23b598"
  },
  "id": "5jfVvbXdepW2YG9U",
  "tags": []
}

Is it possible to pin sample data for the Get Leads node and the Create call vapi nodes?

Id like to try and run it on my end to check how the data is coming

I have pinned the data in above code, you can check

Ok I found the issue. The error occurs when the IF node is not “allEnded” and it goes to wait a second time. Because you now have a nested loop (loop inside a loop), n8n looses track of which item you’re looping for “.item”. This is because you’re semi breaking the loop by by passing the “Create Call - Vapi“ on that second iteration for wait.

Try the following value on the “Fetch Call Details - Vapi“ node and lemme know if this worked:

https://api.vapi.ai/call/{{ $('Create Call - Vapi').all()[$itemIndex].json.id }}
2 Likes

I pinned the data for both the ‘Get Leads’ node and the ‘Create Call - Vapi’ node in the code above.

I came right, check my edited answer above

1 Like

Alright, how does ‘Split in Batches’ actually work? What I mean is: if, at the IF node, some calls have the status ‘ended’ while others do not, the workflow goes back to ‘Wait’ and then checks the call status again using the ‘Fetch Call Details’ node. This means the fetch node will re-check all 10 calls, including those that already had the ‘ended’ status. How can we change the workflow so that once a call has the status ‘ended’, it is not checked again?

Your assumption above is correct. To change the behaviour see if you can add a query on the “Fetch Call Details - Vapi“ to find items where not ended status. This MIGHT cause some problems but worth a try. If not, then we’ll to think about this more and try work an alternative flow.

For this Ill need more context on what Vapi is, what the ended status entails and what you’re trying to achieve in your logic. For example, why are you waiting for all batch iterations to have an ended state?

@Wouter_Nigrini Vapi is a platform that allows us to build Voice Assistants, and through their API I am making outbound calls to potential leads. I am waiting for all batch iterations to finish because Vapi has a concurrency limit of 10 - meaning we can only make 10 calls simultaneously. If we exceed that limit, we would need to design a more complex flow. That is why I check for all 10 calls to reach the ‘ended’ status before starting the next batch. If I create a flow to check whether some slots are available, that would also result in a complex flow. To keep things simple, I wait for all 10 calls to end before moving on

Ok that makes sense. Are you able to then add a condition on the fetch for non ended calls only. Then in your code block make sure to check on the returned item count rather, meaning once no records return, they all ended. Then proceed to the next batch.

This should effectively cause your fetches to reduce as the calls end.

1 Like

So something like below. You can then get rid of the code node

1 Like

Hey everyone! :slight_smile:

Sorry for hijacking…

@Muhammad_Hamza_Azhar, why don t u wait for Vapi to send the end call report?(not necessarily to send request to check if is done).

YOU want to create “round Robin” selections, but is overkill to spamm until you get the ended status.

Simply create another webhook trigger, wait for Vapi to send only the end-call-report(transcript etc), mark as ended in your DB/Sheet …

Let me know if you wanna see a different setup.

Cheers!

@Parintele_Damaskin Yes, I can do that, but then the calls will be sequential - the first call is initiated, and only when it ends does the second call start. If I have 2,000 leads, this will take far too much time. Is there a way we can use the end-call report so that we can run 10 calls simultaneously (since Vapi has a concurrency limit of 10), and then, once those calls have ended, we iterate to the next batch?

To explore @Parintele_Damaskin suggestion a bit more which is a great suggestion, but keeping in mind you want to process batches of 10 and wait for all 10 calls to end before sending the next batch, we’ll need to add more complexity to your workflow. Just throwing an idea here and not sure how @Parintele_Damaskin imagined it on his end.

I’d create a separate webhook which will receive the hook call from Vapi on call statuses and then store that in a db. For this, we would need to add the call to the db after we sent it to Vapi so we have a reference to come back to. Then in the flow you already have, instead of pinging vapi for statuses you just check your internal db for the status.

This essentially has the same outcome, just with more complexity and an additional point of failure such as the db. This would significantly reduce the fetch calls to vapi. However, if Vapi is not rate limiting you on queries at the moment, then this additional complexity is not worth the effort in my opinion.

Keen to hear @Parintele_Damaskin idea

2 Likes