Best practice to get incoming call phone number at...
# support
h
hi, my goal is the following : - when someone calls my bot, I need to get his phone number pretty quickly - this phone number will be used to check if the caller already called in the past days (external service that I communicate with, with make.com) - If it's the case, the bot will have to use previous calls informations, also present in the external service, as context to answer the caller's questions My question is : - I saw that there was a way, using the API, to collect the incoming call phone number using a call ID - I also saw this sentence in this discord """When an incoming call is received, you'll automatically get the id of the call in the response. Use this ID to fetch call details if necessary.""" How is it done ? - Is the best way to do it to trigger a webhook at the begining of the call, that will start a make scenario containing HTTP requests nodes that performs all the required requests ?
v
Hi @hugopdvn, 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 Phone Number]() * [Get Call]() * [Update Phone Number]() -----------------------------
### Answer To achieve your goal of quickly retrieving the phone number of an incoming call when using Vapi, and using this information to check previous interactions or context from an external service, you can indeed leverage the call ID provided by Vapi when a call is initiated. Here’s a general approach to handle this: 1. **Capture the Call ID**: When a call is initiated to your Vapi-powered bot, Vapi automatically provides a call ID in the response. This ID is crucial as it serves as a unique identifier for the call session. 2. **Fetch Call Details**: Using the call ID, you can make an API request to retrieve details about the call, including the caller’s phone number. The specific endpoint to fetch call details can be used for this purpose. Here’s a basic example using cURL:
Copy code
bash
   curl --request GET \
   --url https://api.vapi.ai/call/{id} \
   --header 'Authorization: Bearer <token>'
Replace
{id}
with the actual call ID and
<token>
with your authorization token to perform the request [(1)]() . 3. **Webhooks for Real-Time Processing**: Setting up a webhook at the beginning of the call can be an effective way to trigger external workflows, such as those in make.com. When configuring your Vapi environment, specify the webhook URL that should be contacted upon call initiation. This URL can handle the logic for fetching additional call details and interacting with external systems to pull in relevant context or past interactions. 4. **Use Call Details in Your Service**: Once the webhook is triggered and you retrieve the necessary call details (including the phone number), use this data to query your external service for any past interactions. This helps in personalizing or contextualizing the conversation based on historical data. 5. **Configure Assistant Behavior**: Depending on the information retrieved and the context required, configure your Vapi assistant to handle the call accordingly, using the historical context to guide the conversation flow. This approach ensures that you can dynamically retrieve and utilize caller information to provide a tailored conversational experience. Make sure to secure your webhooks and API calls to protect sensitive data. For more detailed implementation and customization, you might want to review the specific API documentation and ensure your webhook and API endpoint configurations are set up correctly to handle real-time data retrieval and processing .
Got it. Tagging @User for additional help.
h
Need some help with this part : 'Capture the Call ID: When a call is initiated to your Vapi-powered bot, Vapi automatically provides a call ID in the response. This ID is crucial as it serves as a unique identifier for the call session.'
j
Have a look at this example in the docs: https://docs.vapi.ai/examples/inbound-support You don't want to focus on the call_id, instead you should use the call.customer.number
7 Views