{
  "name": "Feb 17 Voice Agent",
  "nodes": [
    {
      "parameters": {
        "inputSource": "jsonExample",
        "jsonExample": "{\n  \"date\": \"\",\n  \"start_time\": \"\",\n  \"end_time\": \"\",\n  \"context\": \"\",\n  \"first_message\": \"\",\n  \"goal\": \"\",\n  \"name\": \"\",\n  \"relationship\": \"\",\n  \"fall_back_plan\": \"\",\n  \"special_requests\": \"\",\n  \"special_request_required\": true\n}"
      },
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "typeVersion": 1.1,
      "position": [
        -140,
        0
      ],
      "id": "29535d6e-dfcd-4551-9c09-08066f840708",
      "name": "When Executed by Another Workflow"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.vapi.ai/call",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer <YOUR_API_KEY>"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"phoneNumberId\": \"ENTER_VALUE_HERE\",\n  \"assistantId\": \"ENTER_VALUE_HERE\",\n  \"customer\": {\n    \"number\": \"ENTER_VALUE_HERE\"\n  },\n  \"type\": \"outboundPhoneCall\",\n  \"assistant\": {\n        \"name\": \"Will\",\n        \"voice\": {\n          \"provider\": \"playht\",\n          \"voiceId\": \"will\"\n        },\n        \"firstMessageMode\": \"assistant-waits-for-user\",\n        \"backgroundSound\": \"off\",\n        \"firstMessage\": \"{{ $('When Executed by Another Workflow').item.json.first_message }}\",\n        \"model\": {\n        \"provider\": \"openai\",\n        \"model\": \"gpt-3.5-turbo\",\n        \"messages\": [\n          {\n            \"role\": \"system\",\n            \"content\": \"{{ $json.message.content.vapi_voice_call_context_prompt }}. If they ask for a call back number, they can reach me at 604-123-4567, and my email is email@gmail.com\"\n        }]\n      }\n    }\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        440,
        0
      ],
      "id": "51c4637c-afeb-4877-8809-ce4d6b43a7f8",
      "name": "HTTP Request"
    },
    {
      "parameters": {
        "url": "=  https://api.vapi.ai/call/{{ $json.id }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer <YOUR_API_KEY>"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        680,
        0
      ],
      "id": "05e6fa28-19bb-452c-be7f-8dd6601e9d6e",
      "name": "HTTP Request1"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        900,
        0
      ],
      "id": "61b7592b-f64e-4c47-9dcf-0e2cdffe40d6",
      "name": "Wait",
      "webhookId": "59fb23df-b7cd-4984-bb43-6b915413af49"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "6317e9c3-fc74-4080-b8af-f24a00c1789b",
              "leftValue": "={{ $json.status }}",
              "rightValue": "ended",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        1120,
        0
      ],
      "id": "2f72e35f-84b8-4e46-b161-caa62b3a3d96",
      "name": "If"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "33999b2c-11b6-41b4-b2c0-9ba40d2cf3f7",
              "name": "call_transcript",
              "value": "={{ $json.transcript }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1420,
        0
      ],
      "id": "8a53fa35-199c-4614-96c7-98d58f2fdf80",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4o",
          "mode": "list",
          "cachedResultName": "GPT-4O"
        },
        "messages": {
          "values": [
            {
              "content": "You're an intelligent voice AI bot that is fantastic at creating prompts and opening call ines for Vapi outbound calls to schedule all types of meetings and appointments, such as barbershops, dinners, etc. for your client Jono.\n\n##Rules\n- The voice agent must sound happy, nice and upbeat. The conversation should be more casual.\n- The voice agent must be as detailed as possible so that Vapi can understand everything about the call and context.\n- Please enter in the backup plan if the goal cannot be met. If this is not provided, then the backup should be to call the place back to re-schedule.\nMake sure to structure the data strictly according to the JSON format provided",
              "role": "system"
            },
            {
              "content": "=Please create a Vapi opening line and call prompt for this type of call:\n {{ $json.context }}\nDate: {{ $json.date }} (if needed)\nStart time: {{ $json.start_time }} (if needed)\nEnd Time: {{ $json.end_time }} (if needed)\nThese times are a range, where I'm available within\nFirst Message: {{ $json.first_message }} (this is just for additional context)\nSpecial Requests: {{ $json.special_requests }}\nIs Special Request Required?\nGoal: {{ $json.goal }}\nName of place you're calling: {{ $json.name }}\nFriend or business: {{ $json.relationship }}\nFall Back Plan: {{ $json.fall_back_plan }}\nContext: {{ $json.context }}\n\n##Context\n- You are an AI voice agent making an outbound call on behalf of you client Jono\n- NEVER under any circumstances pretend like you're working or representing {{ $json.name }}. You're only representing Jono.\n- Your goal is: {{ $json.goal }}\n- The opening line should be the first thing that's said. For example: \"Hello, I'm giving {{ $json.name }} because I'm looking to make a dinner reservation\""
            },
            {
              "content": "Strictly output the response in valid JSON format in 2 text fields. DO NOT PUT THIS INTO AN OBJECT. Only use the two text fields as exactly shown below:\n{\n  \"vapi_voice_call_first_message\": \"\",\n  \"vapi_voice_call_context_prompt\": \"\"\n}\n\nEnsure the response is correctly formatted as JSON, including the curly braces, key names, and values. Do not omit or modify any part of the structure.\n",
              "role": "assistant"
            }
          ]
        },
        "jsonOutput": true,
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        80,
        0
      ],
      "id": "0dca421b-af7e-4ed2-b08c-2d53f63af08f",
      "name": "OpenAI",
      "credentials": {
        "openAiApi": {
          "id": "ijZWPGwLXdAOVFfI",
          "name": "OpenAi account 2"
        }
      }
    }
  ],
  "pinData": {
    "When Executed by Another Workflow": [
      {
        "json": {
          "date": "February 17th 2025",
          "start_time": "5pm",
          "end_time": "8pm",
          "context": "The user is looking to book a dinner reservation tonight between 5-8pm at Tandoori chicken to eat at the restaurant.",
          "first_message": "Hello, I'd like to book a dinner reservation tonight.",
          "goal": "To book a dinner reservation tonight between 5-8pm",
          "name": "Tandoori Chicken",
          "relationship": "business",
          "fall_back_plan": "Please do not book the dinner reservation, instead politely mention that you'll have to call back in 10 minutes if you decide to book",
          "special_requests": "I'd like to get a table by the window",
          "special_request_required": true
        }
      }
    ],
    "OpenAI": [
      {
        "json": {
          "index": 0,
          "message": {
            "role": "assistant",
            "content": {
              "vapi_voice_call_first_message": "Hello, I'm calling Tandoori Chicken because I'm looking to make a dinner reservation.",
              "vapi_voice_call_context_prompt": "Hi there! I'm an AI voice agent reaching out on behalf of my client, Jono. We're looking to book a dinner reservation at Tandoori Chicken for tonight, February 17th, 2025, anytime between 5 PM and 8 PM. Jono would love to have a table by the window if that's possible. If window seats aren't available, that's fine; we just want to ensure a spot within that timeframe. If we can't secure a reservation right away, please let us know, and we'll call back in 10 minutes to try again."
            },
            "refusal": null
          },
          "logprobs": null,
          "finish_reason": "stop"
        }
      }
    ]
  },
  "connections": {
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "OpenAI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "HTTP Request1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request1": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "HTTP Request1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "40a53928-505f-450c-a84a-b614e6567494",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "d2017cc6d1e4b956d269a8123bffa72fb7aaa41ad37a73b7c0fb64c7d0e2edae"
  },
  "id": "XyFfj6eWQZSJw870",
  "tags": []
}