extract the phone number from the incoming call da...
# support
a
I want to extract the "from or number" when receiving the call and pass it to the function/tool call. is it viable?
v
Hi @andromate12357892, 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**: * [Import Vonage Number]() * [List Phone Numbers]() * [Delete Phone Number]() * [Import Twilio Number]() -----------------------------
### Answer Yes, it's viable to extract the phone number from the incoming call data and pass it to a function or tool call within Vapi. When you receive a call on Vapi, you can access the caller's number (often provided as 'from' or 'number') directly from the call object that is passed to your server URL defined for handling the phone number. Here’s a basic overview of how you might handle this using the server URL functionality in Vapi: 1. Set up a server URL in your phone number configuration that points to your server. 2. When a call is received, Vapi sends a POST request to your server URL with the call data, including the caller's number. 3. Extract the 'from' or 'number' from the call data in your server-side code. 4. You can then pass this number to any functions or tools as needed. This functionality relies on the configuration of the server URL and its handling in your backend systems. For more specific details or examples on how to set this up, you would typically refer to the [server URL documentation]() and the associated payload schema available there [(1)]() . Remember to ensure that your server is configured to handle requests securely and efficiently to process the incoming data as required.
Got it. Tagging @User for additional help.
c
It should be, what is the use case though? Wouldn't the number be dynamic already?
a
I have data that can be filtered by phone number and I wish to get the caller number so I can personalise the prompt and interaction. at the moment, i'm getting that info from Twilio but i wish to get that info directly from Vapi and pass it in function calling.
c
Vapi does not have that information. It has information about like the summary of the last call. I hope I just typed that right if I understand you correctly.
It can be dynamic and not remeber the number becuase of the dynamic values you put in the prompt.
You just need to do the JSON part, not JS.
a
@Sahil could you confirm?
@Chowderr thanks but that doesn't work. 🙂
c
It was not meant to work, but serve as an example.
This was the only important part: { "functions": [ { "name": "handleIncomingCall", "async": false, "description": "Handles incoming calls and processes caller's number.", "parameters": { "type": "object", "properties": { "callerNumber": { "type": "string", "description": "The phone number of the incoming caller." } }, "required": ["callerNumber"] }, "serverUrl": "https://your-server-url.com/handle-call", "serverUrlSecret": "your-server-secret" } ] }
a
Yeah, I meant, I have tried it in that way previously but didn't work.
model": { "model": "gpt-3.5-turbo", "tools": [ { "type": "function", "async": false, "server": { "url": "https://c334-86-114-5573-180.ngrok-free.app/inbound" }, "function": { "name": "extractCallerInfo", "parameters": { "type": "object", "required": [ "callSid", "from" ], "properties": { "from": { "type": "string" }, "callSid": { "type": "string" } } }, "description": "Extracts the caller's phone number." }, "messages": [ { "type": "request-start", "content": "Extracting caller information. Please wait..." }, { "type": "request-complete", "content": "Caller information extracted." }, { "type": "request-failed", "content": "I couldn't extract the caller information right now." }, { "type": "request-response-delayed", "content": "It appears there is some delay in communication.", "timingMilliseconds": 2000 } ] } ], "provider": "openai", "maxTokens": 250, "temperature": 0.7 },
s
We send phone number as a parameter whenever an inbound call is being made. You can check out videos in the community section. You will find it. https://docs.vapi.ai/community/videos
39 Views