{
  "name": "Saathi Call Automation",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "saathi-actions",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "webhook-trigger",
      "name": "Webhook Trigger",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        240,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$json.action}}",
              "operation": "equal",
              "value2": "CALL"
            }
          ]
        }
      },
      "id": "call-filter",
      "name": "Call Filter",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        460,
        300
      ]
    },
    {
      "parameters": {
        "url": "https://api.twilio.com/2010-04-01/Accounts/YOUR_ACCOUNT_SID/Calls.json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "twilioApi",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Basic {{Buffer.from('YOUR_ACCOUNT_SID:YOUR_AUTH_TOKEN').toString('base64')}}"
            },
            {
              "name": "Content-Type",
              "value": "application/x-www-form-urlencoded"
            }
          ]
        },
        "sendBody": true,
        "bodyContentType": "form-urlencoded",
        "bodyParameters": {
          "parameters": [
            {
              "name": "To",
              "value": "={{$json.data.recipient}}"
            },
            {
              "name": "From",
              "value": "YOUR_TWILIO_PHONE_NUMBER"
            },
            {
              "name": "Twiml",
              "value": "=<Response><Say voice=\"alice\">{{$json.data.content}}</Say></Response>"
            }
          ]
        },
        "options": {}
      },
      "id": "make-call",
      "name": "Make Call",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [
        680,
        200
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={\"success\": true, \"message\": \"Call initiated successfully\", \"timestamp\": \"{{new Date().toISOString()}}\"}",
        "options": {}
      },
      "id": "success-response",
      "name": "Success Response",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        900,
        200
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={\"success\": false, \"message\": \"Action not supported or failed\", \"action\": \"{{$json.action}}\"}",
        "options": {}
      },
      "id": "error-response",
      "name": "Error Response",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        680,
        400
      ]
    }
  ],
  "connections": {
    "Webhook Trigger": {
      "main": [
        [
          {
            "node": "Call Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Call Filter": {
      "main": [
        [
          {
            "node": "Make Call",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Error Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Make Call": {
      "main": [
        [
          {
            "node": "Success Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {},
  "versionId": "1"
}