plee4722
04/23/2024, 2:14 PMVapi Support
04/23/2024, 2:14 PMVapi Support
04/23/2024, 2:14 PMjson
{
"functions": [
{
"name": "getCityInfo",
"description": "Fetches information for a given city.",
"parameters": {
"type": "object",
"properties": {
"cityName": {
"type": "string",
"description": "The name of the city to fetch information for."
}
}
}
}
]
}
[(1)]()
You'd also need to ensure your server can handle function calls from Vapi. For this, you have to set up an endpoint that matches the specifications described in the Vapi documentation for function calling. When Vapi triggers the getCityInfo
function during a conversation, it will send a POST
request to your server with the specified parameters, in this case, the cityName
.
Your server should process this request, retrieve the city information, and then respond with the result in a format that Vapi can incorporate back into the conversation flow. Here's an example of what the request from Vapi to your server might look like:
json
{
"message": {
"type": "function-call",
"call": { /* Call Object */ },
"functionCall": {
"name": "getCityInfo",
"parameters": "{ \"cityName\": \"New York\"}"
}
}
}
[(2)]()
And your server's response should provide the city information result:Vapi Support
04/23/2024, 2:14 PMjson
{ "result": "New York is known for its vibrant arts scene and towering skyscrapers." }
This result will be incorporated into the conversation flow, allowing your assistant to dynamically provide information based on the user's input.
Make sure your server endpoint is properly configured to receive and respond to these requests. If your assistant's serverUrl
is set, Vapi will send function call information to that URL.
Remember that custom functions give you the flexibility to extend the capabilities of your assistant, enabling dynamic interactions based on your business logic and external data sources.Vapi Support
04/23/2024, 2:16 PMSahil
04/23/2024, 3:40 PM