How to detect an inbound number?
# support
m
How to detect an incoming customer's number?
v
Hi @Mrpoopybutthole, I'm an AI assistant for Vapi. I'll analyze available sources and get back to you shortly.
----------------------------- **While I generate an answer, here are some sources that might be helpful**: * [Create Phone Call]() * [Get Call]() * [List Calls]() * [Outbound Calls from Python]() -----------------------------
### Answer To detect an incoming customer's number in Vapi, you can access this information from the call details. When you receive an inbound call, Vapi provides metadata, including the customer's phone number. You can retrieve this information through the API by making a request to get call details, where the customer's number will be part of the response data. The relevant API endpoint for retrieving call details is documented under "GET Get Call" [(1)]() . This endpoint allows you to fetch details about a specific call by its ID, which includes the customer’s phone number as part of the call metadata. Here's a simple example of how you might retrieve a call's details, which would include the inbound customer's number:
Copy code
python
import requests

# Your Vapi API Authorization token
auth_token = 'YOUR_AUTH_TOKEN'
call_id = 'YOUR_CALL_ID'  # The ID of the call you want to fetch details for

headers = {
    'Authorization': f'Bearer {auth_token}',
}

# Make the GET request to Vapi to retrieve call details
response = requests.get(
    f'https://api.vapi.ai/call/{call_id}', headers=headers)

# Check if the request was successful and print the call's customer number
if response.status_code == 200:
    call_details = response.json()
    customer_number = call_details.get('customer', {}).get('number')
    print(f"Customer's number: {customer_number}")
else:
    print('Failed to retrieve call details')
This code snippet demonstrates how to make a GET request to the Vapi API to obtain details about a specific call, using the call ID. The customer's phone number is extracted from the response data and printed out. Remember to replace
'YOUR_AUTH_TOKEN'
and
'YOUR_CALL_ID'
with your actual Vapi API authorization token and the ID of the call you're interested in, respectively . Please note, the exact structure of the response and the way you access the customer's number may vary based on the API's current implementation, so it's important to refer to the official Vapi documentation for the most accurate and up-to-date information.
2 Views