Real Time Access to Phone Number for Assistant
# support
d
I need help with the following issue. How can a vapi assistant know during an inbound call, the phone number of the caller? I want to pass it through a dynamic variable so that the assistant knows the caller phone it can look up details on them immediately I also want to send the caller phone number on the end of call report to the webhook. Currently we don’t get the caller phone and this is a major piece of info Here is what i have set up so far: To include the phone number of the caller in your system prompt so that your assistant has access to it in real-time during the call, you can use dynamic variables in Vapi. Here's how you can do it: 1. In my system prompt, I included the caller's phone number, For example: The caller's phone number is {{caller_phone_number}}. 2. When starting a call, I need to pass the actual phone number value in the variableValues object within the assistantOverrides parameter. Here's an example of how your API request might look: json { "assistantId": "your-assistant-id", "assistantOverrides": { "variableValues": { "caller_phone_number": "+1xxxxxxxxxx" } }, "customer": { "number": "+1xxxxxxxxxx" }, "phoneNumberId": "your-phone-id" }
v
@Dennis It sounds like you're on the right track with using dynamic variables to pass the caller's phone number to the assistant. To ensure that the assistant knows the caller's phone number during an inbound call, you can use the
assistant-request
message type to retrieve the assistant based on the caller's phone number. Here's what you need to do: 1. When an inbound call is received, Vapi will send an
assistant-request
message to your server with the call object. 2. Your server should then respond with a JSON object containing the assistant and include the
variableValues
object with the
caller_phone_number
variable set to the caller's phone number. For example, your server's response might look like this:
Copy code
json
{
  "assistantId": "your-assistant-id",
  "assistantOverrides": {
    "variableValues": {
      "caller_phone_number": "caller's phone number here"
    }
  }
}
To include the caller's phone number in the end-of-call report sent to the webhook, you'll need to ensure that your system captures this information during the call and includes it in the call report payload. If your current setup does not capture the caller's phone number, you may need to modify your call handling logic to include this information. If you need further assistance with setting this up or have any other questions, please let me know!
You can continue this conversation by mentioning me in the message.
c
It literally comes in the call object? Have you not set this up to look at this?
Granted you have the Voice Assistant ask them for a number if it might be another that is not being used to call inbound
d
i see it in the call object but i want to pass it to the assistant. Which is the problem.
I want to be able to ask the assistant, what's my phone number, and it will tell me since i passed it through the variable
c
Then just put it as the variable. it is literally that simple. I am not sure how you are automating your call process - it kind of sounds like you don't know (I could be wrong) Regardless the number that they are calling with or you are calling is always available to use as a dynamic variable.
d
this is my system prompt, i call the assistant - and i ask it - what's my phone number, it responds that it cant access this information or that it doesn't know. https://cdn.discordapp.com/attachments/1286747961023402095/1286794728485949550/image.png?ex=66ef347a&is=66ede2fa&hm=a950c068a702ae087f6f278530ec9159737e2da1bc2a92f2605bfb2c7a1eb6ce&
i was under the same assumption as you, but it isnt working.
I see you responded to a few other people with the same response, have you been able to do it on your end, by "just pluggin in the variable" and getting the assistant to respond with the phone number you are calling in from?
c
I would not be recommending something that does not work or I have not tried. I assume people have never came back with a comment because they tried it and worked.
Then you are doing it wrong and you need to go read the docs to understand fully or go watch videos from the community. Granted I don't do anything in the dashboard it is the same principles.
d
you're very condescending. I did read the docs, and spent hours trying to figure this out, thats why im here...to get a direct answer from VAPI.
about why their variable isnt working
because it looks like i'm not the only one having this problem
a
@Dennis you can do it by using trasient-based assistant. Check this video start from 28:09:

https://youtu.be/RMOHpWAPan8?feature=shared&t=1689

When you get the phone number from the webhook, you can place it in the prompt.
d
THANK YOU SAVANNAH! This is the route i was going down except hosting my function on AWS Lambda
a
Sure, I'm glad to help.
d
For anyone having this issue. I was able to get this working using a transient based assistant aka. TOOLS. I used pipedream to handle the webhook and server url, Thanks @Aurora
You were wrong in your recommendation. If you have nothing helpful to offer, you should just not waste your time answering questions on discord for people who are seeking help.
c
My guy just joined yesterday and said I wasn't helpful 🤣. I bet you were using the dashboard huh?
d
CONDESCENDING!!!
c
Not at all. It just funny and weird when people do what you do. I am one of the most helpful people in the Discord. You probally made a user error becuase you are new, thats fine. But don't to try blame that other stuff on me. Good luck with your VAPI journey my guy 🙂
40 Views