using dynamic variables for incoming phone calls -...
# support
b
When the user calls in to the assistant I would like to update it with data about the user based on the phone number. For example the user's name. Is that possible?
v
You can continue this conversation by mentioning me in the message.
@beester Absolutely, you can update the assistant with data about the user based on the phone number. To do this, you would typically have a database or a CRM system where user information is stored and associated with their phone numbers. When a user calls in, you can look up their information using their phone number and then update the assistant's context with the relevant data, such as the user's name. To update the assistant with the user's name, you would use the
assistantOverrides
field in the JSON payload that you send to the
/call/phone
endpoint. Here's how you can structure the payload:
Copy code
json
{
  "assistantId": "your-assistant-id",
  "assistantOverrides": {
    "variableValues": {
      "name": "User's Name"
    }
  }
}
Replace
"User's Name"
with the actual name of the user that you retrieved from your database. If you need to make such a call now and you have the user's name ready, please provide me with the user's name and the assistant ID, and I can help you construct the correct JSON payload to send to the endpoint.
b
But that API is for outgoing calls. I want to do this for an incoming call initiated by the user.
v
@beester I apologize for the confusion. For incoming calls, the process would be slightly different. When a user initiates a call to your system, you can capture their phone number as part of the call metadata. You would then use this phone number to look up the user's information in your database. Once you have the user's information, you can update the assistant's context for that specific call. This typically involves using a webhook or an API endpoint on your server that receives events from the incoming call. When you receive the call event, you can respond with the relevant user data to personalize the assistant's responses. If your system supports real-time updates to the assistant's context during an incoming call, you would use the appropriate method to send the user's name and any other relevant information back to the assistant. If you need to know the specific method or endpoint to use for updating the assistant's context during an incoming call, please ask support for more info on this.
b
That sounds great. But I couldn't find any way in the VAPI docs to send that info the the assistant's context during an incoming call.
Can I return data from the status_update call to the server url?
b
ah.. so I create the assistant on the fly! thanks this seems like the right track! but it would be nice to have a different server url for each phone number.
thanks @Chowderr 🙏
c
I am not sure why you think you can't do that.
b
You're right! The docs says that server URLs can be attached to phone numbers themselves. But on the phone number page it says "Either Select an assistant or Please configure a Server URL in the Accounts Page."
c
I mean that does not really matter.
b
I was able to set it using the phone-number api. There doesn't seem to be any other way to set it.
c
Yes, that is correct. Your not meant to do it in the dashboard. Which has way less options then the dashboard.
b
As long as you're being so helpful... I'm having trouble with the response to the "assistant-request". I'm returning a JSON description of the assistant but getting back and error that says: "Couldn't Get Assistant. Either Set The Assistant I D On The Phone Number."
Seeding this back worked just fine... there must have been some subtle problem with what I was returning before: { "assistantId": "b94dc10c-34af-44c6-bc6b-2d2e72f897dc", "assistantOverrides": { "firstMessage": "Hi I'm Gracie. I belive your name is {{name}}", "variableValues": { "name": "George" } } }
c
On the same page it tells you about the request. You need a response webhook with the assistant.
b
I must have had something wrong with my response but the error reporting isn't enought to figure out what I was goig wrorng. In any case @Chowderr thanks for your help it got me unstuck.
c
Works now?
b
I was never able to send up a full assistant because there error reporting didn't indicated what the problem was. but starting with a base assistant and overriding certain fields did work. it would be nice if the error reporting explained exactly what was wrong with the json data.
f
Getting this error: Couldn't Buy Twilio Number. Twilio Error: No phone numbers found
Are certain area codes not available?
Using the phone-number/buy API
s
@beester i hope it is resolved now.
3 Views