Call data within funciton call
# support
a
Is it possible to trigger a function call that contains data like the phone number that called? I know I can get this information from the end of call report, but I need it earlier so I need it from a custom function call. If so, how can I reference this data in order to use it in the custom function call?
v
@Abe Yes, it is possible to trigger a custom function call that includes data such as the phone number that called. To reference this data within your custom function, you would typically use the parameters provided by the VAPI environment, such as
phoneNumberId
or
phoneNumber
object, depending on whether you're using an existing number or a transient number. When you define your custom function, you should specify the parameters it accepts. For instance, if your function needs to know the caller's phone number, you would include a parameter for that in your function's definition. Then, when you trigger the function call, you pass the
phoneNumberId
or
phoneNumber
object to it as an argument. Here's a simplified example of how you might define and call such a function:
Copy code
javascript
// Define your custom function with the necessary parameters
function handleIncomingCall(callerPhoneNumber) {
  // Your logic here, using callerPhoneNumber
}

// Trigger the custom function with the phone number data
handleIncomingCall(phoneNumberId); // If you're using an existing number
// or
handleIncomingCall(phoneNumber); // If you're using a transient number
In the context of VAPI, you would ensure that your function is set up to be called with the appropriate event or trigger that provides the phone number data. If you need further assistance with setting up or triggering your custom function, please ask support for more info on this.
You can continue this conversation by mentioning me in the message.
j
If you look up transient assistants in the docs, you can extract the phone number before the call starts from the assistant-request. Then you can add the phone number to your prompt and the LLM will be able to send it within it's custom functions/tools
c
That information already comes in - why would you make a tool call for that?
s
check server event of type request assistant and use assistant overrides and request payload to get and send call object.
for more check: https://docs.vapi.ai