Get caller phone number
# support
l
Hi! I have an assistant to attend inbound calls. I have configured via SIP, so my assistant phone number is something like "sip:601123123@sip.vapi.ai". I am using a prompt without workflows. I am trying to get the caller id (phone number who makes the call) in the assistant, but I don't achieve. I have tried with {{customer.number}}, {{caller.phoneNumber}} and others, but I can't get it. Could you help me please? Which variable can I use? How can I get the caller phone number? Thank you!
v
To get the caller's phone number in your SIP-configured Vapi assistant, use the
{{customer.number}}
variable in your prompt. This variable contains the caller's phone number in E.164 format (with the "+" prefix). The caller's number is extracted from the
From
field in the SIP request body and passed to Vapi as
customer.number
. Here's an example of how it's processed:
Copy code
python
From = request_body.get("From", "")
payload = {
    # other fields...
    "customer": {
        "number": From
    },
}
Sources: - [Discord Channel](https://discord.com/channels/1211482211119796234/1343574701909344297) - [Vapi Documentation](https://docs.vapi.ai/assistants/dynamic-variables)
k
Pass it via a custom SIP header like X-Caller-Number, then access it using a dynamic variable such as {{caller_number}} in your prompt.
l
It doesn't work. Assistant say that can't access to that information or tell me a random number
I haven't access to configure the origin
k
You’ll need to set up a webhook to extract the caller’s number from the SIP From header during the assistant request event and pass it to the assistant as a dynamic variable..
l
how can I do this?
configuring a Tool function that request VAPI with the current call_id?
k
Set a serverUrl in your assistant to handle assistant request events via a webhook that extracts the caller's number from the SIP From header and returns it as a variable like caller number for use in prompts.
l
Sorry, I don't understand the way to do this. I have an assistant and a SIP number associated. I can call via SIP sophone with the assistant. How I can obtain the caller number? I have tried with {{customer.number}}, but it doesn't work. Is it necessary to build a function tool or something similar? I don't know how events work in VAPI.
I have read that, but I don't want to transfer my call outside, I want the call to be attended by my assistant
k
To keep calls handled by your assistant and prevent transfers, remove any transferCall tools, adjust prompts to avoid suggesting transfers, and verify your server logic doesn’t trigger external handoffs.
l
Sorry, but I have configured this simple prompt using that dynamic variable and doesn't work
k
Hey! To help track down this issue, could you share: - The call ID - When exactly this happened (the timestamp) - What response you expected to get - What response you actually got instead This would really help us figure out what went wrong!
l
- Call ID: 4b88e006-e1a0-43a1-bbc3-c0faee27cf51 - Time: 24 abr 2025, 16:12 - I have called from 671035774, so I expected to get "671035774" - Assistant say me anything or that he can't access to phone numbers
this is my prompt: # Número del usuario Si el usuario quiere consultar su número, es este: {{customer.number}}
k
"customer": { "name": "919770169", "sipUri": "sip:919770169@44.229.228.186:5060" } { "role": "system", "time": 1745503969278, "message": "# Número del usuario\\nSi el usuario quiere consultar su número, es este: ", "secondsFromStart": 0 } As you can see in the above logs the customer.number doesn't exists that's why it was empty. instead you have to pass the customer number through assistant overrides as of know we have don't have dynamic variable for {{customer.sipUri}}.
You can raise an feature request for sip dynamic variable over here: https://roadmap.vapi.ai
l
And how can I get the caller id?
customer.sipUri is where I am calling to?
Is it possible to get the callerId if I send it in a custom field?
I have sending in the From header
k
Hey, Could you please schedule a brief call at your convenience so we can discuss this matter in detail? Kindly use the following link to book a suitable time: .
l
Thank you very much for your help in the call. Problem solved!
v
To pass the SIP caller ID to your Vapi assistant, extract it from the SIP "From" header in your backend and include it in the assistant overrides. For example, in Node.js (Express):
Copy code
js
app.post("/api/assistant-selector", (req, res) => {
  // Example: extract caller ID from SIP "From" header (pseudo-code)
  const sipFromHeader = req.headers['from'];
  const callerId = parseCallerId(sipFromHeader); // Implement this function as needed

  res.json({
    assistantId: "your-assistant-id",
    assistantOverrides: {
      variableValues: {
        callerId: callerId
      }
    }
  });
});
Now, you can use
{{callerId}}
as a dynamic variable in your assistant's prompts.
Note: You must implement the SIP header parsing logic appropriate to your environment. Sources: - [Personalization with user information](https://docs.vapi.ai/assistants/personalization) - [Using dynamic variables in a phone call](https://docs.vapi.ai/assistants/dynamic-variables) - [SIP integration](https://docs.vapi.ai/advanced/sip)
To pass the caller ID to your Vapi assistant, extract it from the SIP "From" header on your backend and include it as a dynamic variable in your call request. For example, if your backend receives a SIP header like:
Copy code
From: "34605160984" <sip:34605160984@185.237.200.99>
You can set up your call request as:
Copy code
json
{
  "assistantId": "your-assistant-id",
  "assistantOverrides": {
    "variableValues": {
      "callerId": "34605160984"
    }
  },
  "customer": {
    "number": "34605160984"
  },
  "phoneNumberId": "your-phone-id"
}
This way, you can use
{{callerId}}
or
{{customer.number}}
in your assistant's prompts.
Note: There is currently no built-in dynamic variable for `{{customer.sipUri}}`; you must handle extraction and mapping yourself ([see docs](https://docs.vapi.ai/assistants/dynamic-variables)). Sources: - [Using dynamic variables in a phone call](https://docs.vapi.ai/assistants/dynamic-variables) - [SIP integration](https://docs.vapi.ai/advanced/sip)
k
Marking this ticket as Solved ✅
8 Views