Retrieve called number in a variable
# support
j
Hi there Is there a way to retrieve the called phone number (the one linked to the agent) as a variable similar to what we have with the caller's number in {{customer.number}}?
v
You can retrieve the called phone number by extracting it from the call payload in your server endpoint and passing it as a custom variable. Here’s a quick example:
Copy code
javascript
app.post("/api/assistant-selector", (req, res) => {
  const calledNumber = req.body.call.to.phoneNumber;
  res.json({
    assistantId: "your-assistant-id",
    assistantOverrides: {
      variableValues: { calledNumber }
    }
  });
});
Now you can use
{{calledNumber}}
in your assistant's prompts. This approach gives you the called number as a variable for use in your assistant's messages ([documentation](https://docs.vapi.ai/assistants/personalization)). Source: - [Personalization with user information](https://docs.vapi.ai/assistants/personalization)
c
Hi JoachimChauvet, To retrieve a phone number using the Vapi API, you can use the
GET
request to the
/phone-number/{id}
endpoint. Ensure you include the phone number ID in the path and the authorization token in the header. Here's a quick example in Python:
Copy code
python
from vapi import Vapi

client = Vapi(token="YOUR_API_KEY")
response = client.phone_numbers.get(id="PHONE_NUMBER_ID")
For more detailed information, you can refer to the [Get Phone Number API documentation](https://docs.vapi.ai/api-reference/phone-numbers/get).
3 Views