like-gold
like-gold5h ago

How to pass assistant phone number to tool call?

I have an assistant that handles inbound calls from multiple phone numbers. When the call starts, I need the assistant to call my API to get organization info for the phone number that the customer called on. I'm able to call my endpoint, but I'm having trouble passing the phone number that was called. It seems that the agent is not able to access that information. Part of my prompt looks like this:
### Introduction
1. Before you speak, fetch organization data with `getOrganizationData`, passing `{{assistant.number}}` as `calledNumber`, so the request body will look like this:

{
"calledNumber": "{{assistant.number}}"
}
### Introduction
1. Before you speak, fetch organization data with `getOrganizationData`, passing `{{assistant.number}}` as `calledNumber`, so the request body will look like this:

{
"calledNumber": "{{assistant.number}}"
}
ChatGPT suggested using {{assistant.number}}, but apparently that's not a valid Vapi variable. Is there another way that I can identify which phone number was called. Also, is there a place where we can see what Vapi variables are available? My fallback plan is to pass the callId, and then correlate that with a webhook event, but it doesn't seem to want to pass me {{call.id}} either. I am able to pass {{caller.number}}, so at least some Vapi variables are working, but that doesn't help me much for this specific use case. If I hardcode the number, the API call succeeds and returns data, so I know that everything about my configuration is correct, except for the passing of the called phone number. Thanks for any info you can provide.
3 Replies
Vapi
Vapi5h ago
You should use {{customer.number}} to reference the phone number that was called. Update your tool call payload like this:
{
"calledNumber": "{{customer.number}}"
}
{
"calledNumber": "{{customer.number}}"
}
This will dynamically insert the destination number for each inbound call, as supported by Vapi's variable system (documentation). Source: - Variables Vapi Documentation
⤵️ Mention @Vapi Support Bot for follow-ups 🐥
like-gold
like-goldOP4h ago
@Duckie The {{customer.number}} is the number that is being called from. I verified this by inspecting the value in my API call. I need to know the number that is being called on my inbound call.
Vapi
Vapi4h ago
Thank you for clarifying that {{customer.number}} returns the caller's number in your inbound scenario. To help pinpoint the issue, could you share whether you are using a custom server endpoint (Server URL) to handle inbound calls, and if so, are you able to see the called (destination) number in the webhook payload sent by Vapi? This will help determine if the number is accessible at the server level, even if not directly as a dynamic variable in the assistant prompt. Source: - Variables Vapi Documentation

Did you find this page helpful?