How to get assistant number during call
# support
m
Hello we are trying to get the assistant number (number that was called to reach the assistant) to call a tool but nothing is working, is there any way to get this from any context or variable when calling a tool? thanks beforehand. we are creating the tool like this with the sdk, we have tried with different variable like {{context.call.to}} {{phoneNumber}} but nothing works, the agent doesnt resolve tha variable an calls the API with the string /list/**{{context.call.to}}** const tool = await this.vapiClient.tools.create({ type: 'apiRequest', name: 'getList', description: 'Fetches the list of available details for agent\'s phone number by making an API request to the endpoint.', method: 'GET', url:
${apiUrl}/list/{{context.call.to}}
, credentialId: 'XXXXX', headers: { type: 'object', properties: { 'Content-Type': { type: 'string', value: 'application/json' } } },
v
Thank you for sharing your approach and the variables you've tried. Based on the documentation, there isn't a clearly documented default variable for the assistant's own phone number (the number dialed to reach the assistant) in tool calls—variables like
{{customer.number}}
are available, but not
{{context.call.to}}
or
{{phoneNumber}}
. Could you clarify if you are initiating the call as an inbound call to a Vapi-managed phone number, and if so, do you have access to the phone number's ID or configuration in your call setup? This will help determine if there's a way to inject the assistant's number as a custom variable or retrieve it from the call context. Source: - [Vapi Dynamic Variables Documentation](https://docs.vapi.ai/assistants/dynamic-variables)
m
It's a call to vapi-managed phone numbers, but could be also twilio or others, so basically need to know what number the customer called so that it reached the assistant
a
Hi
m
Hi, @Vapi Support Bot are there any other options?
v
Currently, there is no built-in variable to access the assistant's own phone number (the number dialed by the customer) during a call in Vapi. If you need this value in your tool calls, the recommended approach is to inject it as a custom variable (e.g.,
assistantNumber
) when initiating the call, and then reference it as
{{assistantNumber}}
in your tool URL:
Copy code
js
// When starting the call, add:
assistantOverrides: { variableValues: { assistantNumber: '+1234567890' } }
// Then use {{assistantNumber}} in your tool definition
For now, there is no default variable like
{{context.call.to}}
or
{{phoneNumber}}
that provides this automatically during the call. See the [Vapi Dynamic Variables documentation](https://docs.vapi.ai/assistants/dynamic-variables) for more details. Source: - [Vapi Dynamic Variables documentation](https://docs.vapi.ai/assistants/dynamic-variables)
c
Hi @Martin9sek, As the Vapi bot suggested, there is no inbuilt way to get the assistant's own phone number. and the only way is to use the
assistantOverrides
to pass the phone number during the initiation of the call.
m
hello, reopening this, I swa there is now a way to get this through vapi inbuilt variable {{phoneNumber.number}}. is there anyway to get this populated during web call testing, chat or so and not only with real calls?
c
Hey @Martin9sek, Yes, you can populate the phoneNumber.number variable by using variableValues while testing using webcalls, you need to add it as dynamic variable
Copy code
variableValues: {
  phoneNumber: {
    number: "1234"
  }
}
You can find more information from here: https://docs.vapi.ai/assistants/dynamic-variables Note that you can populate this in a webcall, but you cannot add dynamic variables while testing calls inside vapi dashboard.