ema
05/15/2024, 12:30 AMVapi Support
05/15/2024, 12:30 AMVapi Support
05/15/2024, 12:30 AMfunctions array. Here is an example of how you might define a custom function:
json
{
"functions": [
{
"name": "sendUserMessage",
"description": "Send the user's message to the hosted function.",
"parameters": {
"type": "object",
"properties": {
"message": {
"type": "string",
"description": "The user's message."
}
}
}
}
]
}
[(1)]()
2. **Server URL Configuration**: Make sure that the serverUrl is correctly set in your assistant configuration when creating or updating the assistant. This URL is where Vapi will send the function call information.
json
{
"serverUrl": "https://your-function-url"
}
[(2)]() , [(3)]() , [(4)]()
3. **Handling Function Calls**: Ensure that your server correctly handles the POST requests and returns the appropriate response:
json
{
"message": {
"type": "function-call",
"call": { "Call Object" },
"functionCall": {
"name": "sendUserMessage",
"parameters": "{ \"message\": \"User's input\"}"
}
}
}Vapi Support
05/15/2024, 12:30 AMjson
{
"result": "Function executed successfully"
}
If all these configurations are correct and it still doesn't work, you might have to check your server logs for any errors or issues with the function execution.