{
  "name": "My workflow",
  "nodes": [
    {
      "parameters": {
        "content": "## Sequential Calling System\n\nCalls customers one by one, waits for hangup, marks status, then proceeds to next call.",
        "height": 120,
        "width": 464
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1728,
        1024
      ],
      "id": "6fced66f-f955-458c-a918-1d9d53918416",
      "name": "Sticky Note"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        1344,
        880
      ],
      "id": "655042ea-e8ec-4994-be0e-0a687149d40e",
      "name": "When clicking \u2018Execute workflow\u2019"
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "sheetName": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        1568,
        880
      ],
      "id": "5d97be24-1168-403d-8fc4-9d385bb7c6c9",
      "name": "Get Customer Details",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "47e030bb-0e36-4c4b-acb3-42f69d26ecbe",
              "leftValue": "={{ $json.Status }}",
              "rightValue": "=call left",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        1792,
        880
      ],
      "id": "47b17e4d-9e7d-45f2-a1d1-da6f22f0755e",
      "name": "Customer Left to Call"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.limit",
      "typeVersion": 1,
      "position": [
        2048,
        864
      ],
      "id": "5a78ce65-e369-4733-a4f2-9eb8b14ae55e",
      "name": "One customer at a time"
    },
    {
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "sheetName": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "row_number": "={{ $json.row_number }}",
            "Status": "calling",
            "Customer Name": "={{ $json['Customer Name'] }}",
            "Phone Number": "={{ $json['Phone Number'] }}"
          },
          "matchingColumns": [
            "row_number"
          ],
          "schema": [
            {
              "id": "Slot ID",
              "displayName": "Slot ID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Doctor Name",
              "displayName": "Doctor Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Specialization",
              "displayName": "Specialization",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Date",
              "displayName": "Date",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Start Time",
              "displayName": "Start Time",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "End Time",
              "displayName": "End Time",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Status",
              "displayName": "Status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Customer Name",
              "displayName": "Customer Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone Number",
              "displayName": "Phone Number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "displayName": "row_number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "canBeUsedToMatch": true,
              "readOnly": true,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        2256,
        864
      ],
      "id": "2f877eff-e800-48a3-9ee1-5d0ef1923da9",
      "name": "Mark Status as \"Calling\"",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.videosdk.live/v2/sip/call",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "YOUR_VIDEOSDK_AUTH_TOKEN"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "gatewayId",
              "value": "YOUR_GATEWAY_ID"
            },
            {
              "name": "sipCallTo",
              "value": "={{ \"+\" + $json['Phone Number'] }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        2464,
        864
      ],
      "id": "4f8d5f76-e2d6-4ced-bd64-87487bbf9fc6",
      "name": "Calling Customer"
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "/call-events",
        "responseMode": "streaming",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        1600,
        1184
      ],
      "id": "63f68b5a-e36e-4158-981d-605559122d38",
      "name": "Capturing Call Events"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "e3cb7f8d-0752-4a8a-ba64-faa14951d67f",
              "leftValue": "={{ $json.body.webhookType }}",
              "rightValue": "=call-hangup",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        1808,
        1184
      ],
      "id": "04b547fb-ea89-4d99-bb7f-e7fe231651e3",
      "name": "If user Hangup the Call"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "369904b8-7ac0-4fe2-bfb9-b156b89c909e",
              "name": "phone_number",
              "value": "={{ $json.body.data.to.replace('+','').trim() }}\n",
              "type": "number"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        2064,
        1168
      ],
      "id": "45b1de87-cb7c-4e96-a822-8f1f2a874213",
      "name": "Extract Phone Number"
    },
    {
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "sheetName": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Phone Number": "={{ $json.phone_number }}",
            "Status": "call done"
          },
          "matchingColumns": [
            "Phone Number"
          ],
          "schema": [
            {
              "id": "Slot ID",
              "displayName": "Slot ID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Doctor Name",
              "displayName": "Doctor Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Specialization",
              "displayName": "Specialization",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Date",
              "displayName": "Date",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Start Time",
              "displayName": "Start Time",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "End Time",
              "displayName": "End Time",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Status",
              "displayName": "Status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Customer Name",
              "displayName": "Customer Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Phone Number",
              "displayName": "Phone Number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "row_number",
              "displayName": "row_number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "canBeUsedToMatch": true,
              "readOnly": true,
              "removed": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        2288,
        1168
      ],
      "id": "2759433f-745f-46ed-bf8f-7e7395976f9b",
      "name": "Marking Call Completed",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "sheetName": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "filtersUI": {
          "values": [
            {
              "lookupColumn": "Booking Status",
              "lookupValue": "Pending"
            },
            {
              "lookupColumn": "Status",
              "lookupValue": "calling"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheetsTool",
      "typeVersion": 4.7,
      "position": [
        928,
        1168
      ],
      "id": "a391ef4d-4d91-4697-8802-f7c4262c01ce",
      "name": "get_customer_data",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "sheetName": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Slot ID": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Slot_ID__using_to_match_', ``, 'string') }}",
            "Booking Status": "Cancelled"
          },
          "matchingColumns": [
            "Slot ID"
          ],
          "schema": [
            {
              "id": "Slot ID",
              "displayName": "Slot ID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Doctor Name",
              "displayName": "Doctor Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Specialization",
              "displayName": "Specialization",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Date",
              "displayName": "Date",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Start Time",
              "displayName": "Start Time",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "End Time",
              "displayName": "End Time",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Booking Status",
              "displayName": "Booking Status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Customer Name",
              "displayName": "Customer Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Phone Number",
              "displayName": "Phone Number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Status",
              "displayName": "Status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "row_number",
              "displayName": "row_number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "canBeUsedToMatch": true,
              "readOnly": true,
              "removed": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheetsTool",
      "typeVersion": 4.7,
      "position": [
        1232,
        1168
      ],
      "id": "d7880767-8bc8-4b97-98e7-a1610c56a2cf",
      "name": "cancel_booking",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "sheetName": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Slot ID": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Slot_ID__using_to_match_', ``, 'string') }}",
            "Booking Status": "Booked"
          },
          "matchingColumns": [
            "Slot ID"
          ],
          "schema": [
            {
              "id": "Slot ID",
              "displayName": "Slot ID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Doctor Name",
              "displayName": "Doctor Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Specialization",
              "displayName": "Specialization",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Date",
              "displayName": "Date",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Start Time",
              "displayName": "Start Time",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "End Time",
              "displayName": "End Time",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Booking Status",
              "displayName": "Booking Status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Customer Name",
              "displayName": "Customer Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Phone Number",
              "displayName": "Phone Number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Status",
              "displayName": "Status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "row_number",
              "displayName": "row_number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "canBeUsedToMatch": true,
              "readOnly": true,
              "removed": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheetsTool",
      "typeVersion": 4.7,
      "position": [
        1088,
        1168
      ],
      "id": "28f30e69-cccb-431b-b1c1-9303092879e8",
      "name": "confirmed_booking",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "path": "6b132ac6-2f2d-4276-89c8-8a8783d22489"
      },
      "type": "@n8n/n8n-nodes-langchain.mcpTrigger",
      "typeVersion": 2,
      "position": [
        976,
        944
      ],
      "id": "fad88760-84de-4300-85e6-f24e36ce8316",
      "name": "MCP Server Trigger"
    }
  ],
  "connections": {
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "Get Customer Details",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Customer Details": {
      "main": [
        [
          {
            "node": "Customer Left to Call",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Customer Left to Call": {
      "main": [
        [
          {
            "node": "One customer at a time",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "One customer at a time": {
      "main": [
        [
          {
            "node": "Mark Status as \"Calling\"",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Mark Status as \"Calling\"": {
      "main": [
        [
          {
            "node": "Calling Customer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Capturing Call Events": {
      "main": [
        [
          {
            "node": "If user Hangup the Call",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If user Hangup the Call": {
      "main": [
        [
          {
            "node": "Extract Phone Number",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Phone Number": {
      "main": [
        [
          {
            "node": "Marking Call Completed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Marking Call Completed": {
      "main": [
        [
          {
            "node": "Get Customer Details",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "get_customer_data": {
      "ai_tool": [
        [
          {
            "node": "MCP Server Trigger",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "cancel_booking": {
      "ai_tool": [
        [
          {
            "node": "MCP Server Trigger",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "confirmed_booking": {
      "ai_tool": [
        [
          {
            "node": "MCP Server Trigger",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "availableInMCP": false
  },
  "versionId": "82740414-2455-4784-b11a-dc2b84cddc5d",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "6EvgKrtvfYcvaf8D",
  "tags": []
}