Can Vapi act on responses from custom functions?
# support
v
Hi @Will, I'm an AI assistant for Vapi. I'll analyze available sources and get back to you shortly.
w
I know that we can call custom functions (https://docs.vapi.ai/assistants/function-calling#custom-functions). Can Vapi wait for a response from that function and then act with a new prompt?
v
----------------------------- **While I generate an answer, here are some sources that might be helpful**: * [Function Calling]() * [Server Events]() * [Call Analysis]() * [Dynamic Variables]() -----------------------------
### Answer Yes, Vapi can indeed act on responses from custom functions. When you define a custom function, you can configure it such that Vapi waits for a response from the function and then continues the conversation based on that response. This is facilitated through the use of a
serverUrl
where the function call information is sent, and the response from your server can influence the subsequent actions or prompts of the assistant [(1)]() , [(2)]() . Here's an example of how a function might be set up to send an email and act based on the response:
Copy code
json
{
  "functions": [
    {
      "name": "sendEmail",
      "description": "Used to send an email to a client.",
      "parameters": {
        "type": "object",
        "properties": {
          "emailAddress": { "type": "string" }
        }
      }
    }
  ]
}
When this function is triggered, Vapi sends the function call to the specified
serverUrl
. The assistant can then process the server’s response to determine the next steps in the conversation. This setup is particularly useful for creating dynamic and responsive voice applications where real-time decision making is crucial based on external data or operations.
Got it. Tagging @User for additional help.
w
@User When making a function call, can we use the entire transcript up to that point as a parameter?
s
Basically, think of it as you are appending the custom function response to your assistant. So, it might work in some cases and it might not work.
w
@tekkie
4 Views