Chaim T
05/22/2024, 5:42 PMVapi Support
05/22/2024, 5:42 PMVapi Support
05/22/2024, 5:43 PMfunction-call message type to integrate this custom function.
2. **Configure the Function**: Define a function in the functions array of your assistant's model. This function should be capable of making an HTTP GET request to your Google Apps Script URL. You'll pass the address as a query parameter.
3. **Handling the Function in Server Code**: On your server, you'll need to handle the function call by making an HTTP request to the Google Apps Script. Depending on the response ("valid address" or "error message"), your server can then send the appropriate response back to the assistant.
4. **Assistant Uses the Function**: In the conversation flow, when an address is provided by the user, your assistant should trigger this function, sending the address to your server, which in turn calls the Google Apps Script.
Here is an example of how you might define the assistant model and a custom function in your JSON configuration:Vapi Support
05/22/2024, 5:43 PMjson
{
"model": {
"provider": "openai",
"model": "gpt-3.5-turbo",
"functions": [
{
"name": "verifyAddress",
"description": "Verifies the address using a Google Apps Script",
"parameters": {
"type": "object",
"properties": {
"address": {
"type": "string",
"description": "The address to verify."
}
}
}
}
]
},
"firstMessage": "Hello! Please provide the address you want to verify."
}
[(1)]()
Ensure that your server handling the function-call type messages is set up to make an HTTP GET request to the Google Apps Script URL with the address parameter. Here's a basic example of how the server might handle this:
javascript
const axios = require('axios');
async function handleVerifyAddress(address) {
try {
const response = await axios.get(`https://script.google.com/macros/s/app_script_ID/exec`, {
params: {
func: 'VerifyAddress',
address: address
}
});
return response.data; // Response from Google Script
} catch (error) {
console.error('Failed to verify address:', error);
return "Error verifying address.";
}
}
Integrate these configurations and code snippets into your system to enable your Vapi assistant to verify addresses through your Google Apps Script. Ensure your Google Apps Script is properly set to accept requests and return the expected results based on the inputs it receives.Vapi Support
05/22/2024, 7:06 PMSahil
05/23/2024, 2:13 AMChaim T
05/23/2024, 5:59 PMSahil
05/23/2024, 6:04 PM