hosted functions
# support
e
what is the structure of the return function that needs vapi to can request by a post request?
v
Hi @ema, 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**: * [Connecting Your Custom LLM to Vapi: A Comprehensive Guide]() * [Tools Calling]() * [Get Assistant]() * [Create Assistant]() -----------------------------
### Answer To handle function calls made by Vapi and return a response, your server should respond with a JSON object containing the function's result. The basic structure for the response is as follows:
Copy code
json
{
    "result": "Your function result here"
}
If the result is more complex, it can be an object:
Copy code
json
{
    "result": {
        "message": "Your function result here",
        "extraData": "Additional data if needed"
    }
}
Here is a breakdown of the steps: 1. Receive the POST request at your server URL with the function call details. 2. Process the request and perform the necessary actions. 3. Respond with a JSON object containing the result. For example, if Vapi sends a function call like this:
Copy code
json
{
    "message": {
        "type": "function-call",
        "call": { /* Call Object */ },
        "functionCall": {
            "name": "sendEmail",
            "parameters": "{ \"emailAddress\": \"john@example.com\" }"
        }
    }
}
Your server should respond with:
Copy code
json
{
    "result": "Your email has been sent."
}
Or for a more detailed response:
Copy code
json
{
    "result": {
        "message": "Your email has been sent.",
        "email": "john@example.com"
    }
}
This response will then be used by Vapi to continue the conversation or perform further actions as necessary [(1)]() . : [Server Events]()