First, we need to point your phone number to your server:

  1. You'll need to update your phone number settings using a simple API call. Just plug in your phone number ID, auth key, and server URL into this curl command:
curl -X PATCH <https://api.vapi.ai/phone-number/insert-your-phone-number-id-here> \\\\
     -H "Authorization: Bearer insert-your-key-here" \\\\
     -H "Content-Type: application/json" \\\\
     -d '{
  "serverUrl": "insert-your-server-url-here"
}'

  1. If you've got any assistants or squads already linked to your phone number, let's clear those out:
curl -X PATCH <https://api.vapi.ai/phone-number/insert-your-phone-number-id-here> \\\\
     -H "Authorization: Bearer insert-your-key-here" \\\\
     -H "Content-Type: application/json" \\\\
     -d '{
  "assistantId": null,
  "squadId": null
}'

  1. Now for the cool part! Just before each call starts, Vapi will ping your server asking which assistant to use. This is your chance to set up any dynamic variables you need. Your response should look something like this:
{
  "name": "using-dynamic-variables",
  "assistantId": "insert-your-assistant-id-here",
  "assistantOverrides": {
    "variableValues": {
      "insertVariableNameHere": "insertVariableValueHere",
      "dynamicVariableKey": "dynamicVariableValue"
    }
  }
}

Quick tips to remember: