{
  "id": "2szamFl9EWRq9vWT",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Automate Call with Ultravox Agent and Twilio",
  "tags": [],
  "nodes": [
    {
      "id": "b43c0724-3e62-4d39-b23e-2bb2d7f3febf",
      "name": "Create Ultravox Call",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        176,
        112
      ],
      "parameters": {
        "url": "=https://api.ultravox.ai/api/agents/{{ $json.agent_id }}/calls ",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "medium",
              "value": "={{\n{\n  twilio: {}\n}\n}}"
            }
          ]
        },
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "a3c5dc92-9db1-41c1-ad42-c2ac256220d3",
      "name": "Start Manually",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -320,
        112
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "d69ed985-132d-417c-a073-7d48f6e42d0d",
      "name": "Twilio Call",
      "type": "n8n-nodes-base.twilio",
      "position": [
        384,
        112
      ],
      "parameters": {
        "to": "={{ $('Set Params').item.json.phone_number }}",
        "from": "={{ $('Set Params').item.json.twilio_number }}",
        "twiml": true,
        "message": "=<Response><Connect><Stream url=\"{{ $json.joinUrl }}\"/></Connect></Response> ",
        "options": {},
        "resource": "call"
      },
      "credentials": {
        "twilioApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "7b8b2f16-68e2-4bda-8f20-49468166e72a",
      "name": "Set Params",
      "type": "n8n-nodes-base.set",
      "position": [
        -80,
        112
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "3281eadf-55e5-4aa5-b1c6-7d676d5be3ec",
              "name": "agent_id",
              "type": "string",
              "value": "xxxxxx-xxxxx-xxxxx-xxxxxxxxxxx"
            },
            {
              "id": "bbda4e33-1520-4973-80d8-957480e60a81",
              "name": "twilio_number",
              "type": "string",
              "value": "+1xxxxxx"
            },
            {
              "id": "7e031906-ae2b-4c02-9e11-43ff39a84351",
              "name": "phone_number",
              "type": "string",
              "value": "+1xxxxxxx"
            }
          ]
        }
      },
      "executeOnce": false,
      "typeVersion": 3.4
    },
    {
      "id": "52f76fc0-bf28-4e56-9548-35837bdec2d8",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -320,
        -832
      ],
      "parameters": {
        "color": 3,
        "width": 800,
        "height": 272,
        "content": "## Automated Outbound Calls: connect Ultravox AI Agents to Phone Calls with Twilio\n\nThis workflow transforms n8n into a call automation system, where AI agents can talk directly with people over the phone using Twilio.\n\nThis workflow integrates Ultravox AI voice agents with Twilio\u2019s telephony service to fully automate outbound phone calls\n\nUltravox generates the AI conversation and audio, while Twilio handles the PSTN connection to the actual phone network, with the two services connected in real-time via a media stream."
      },
      "typeVersion": 1
    },
    {
      "id": "a71aa1fb-7dcd-45e2-850d-728d3436c9f7",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -320,
        -528
      ],
      "parameters": {
        "width": 800,
        "height": 224,
        "content": "## STEP 1 - Buy a Phone Number on Twilio\n- Log into your [Twilio Console](https://www.twilio.com/)\n- Navigate to Phone Numbers\n- Search for Available Numbers\n- Select Your Number\n- Click \"Buy This Number\" to finalize the purchase\n- Get \"Accound SID\" and \"Auth Token\" and set these in \"Twilio Call\" node\n- Set 'twilio_number' in \"Set Params\" node (+1xxxxxxxxxx)\n"
      },
      "typeVersion": 1
    },
    {
      "id": "34a2ff34-0868-4452-ab3c-cdc1c2a72a30",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -320,
        -272
      ],
      "parameters": {
        "width": 800,
        "height": 176,
        "content": "## STEP 2 - Create an Agent on Ultravox\n- Log into your [Ultravox App](https://app.ultravox.ai/)\n- Click on \"Agents\" and \"New Agent\"\n- Set Voice, Tools (optional), System Prompt\n- Save and get your Agent ID\n- Set 'agent_id' in \"Set Params\" node\n"
      },
      "typeVersion": 1
    },
    {
      "id": "ff1a5d6a-8475-4c37-bb8b-403cd8d36c36",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -320,
        -64
      ],
      "parameters": {
        "width": 800,
        "height": 112,
        "content": "## STEP 3 - Make a Call\n- Set your 'phone_number' in \"Set Params\" node\n- Execute WF"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "0be19839-e84f-4a06-b5f3-9c1f6f679c3e",
  "connections": {
    "Set Params": {
      "main": [
        [
          {
            "node": "Create Ultravox Call",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Twilio Call": {
      "main": [
        []
      ]
    },
    "Start Manually": {
      "main": [
        [
          {
            "node": "Set Params",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Ultravox Call": {
      "main": [
        [
          {
            "node": "Twilio Call",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}