Cannot return boolean value from Tools call
# support
m
I wrote a tool that checks my calendar to see if I am available given a specific time slot. The endpoint takes the google auth token, start time and end time, then returns the following: # Return the availability in the required VAPI format return jsonify({ "results": [ { "result": is_available # Return the result of the availability check } ] }), 200 In this case, is_available is "true". However the AI assistant says, "Sorry, it seems that I am having problems checking Michael's availability". Can you tell me what is wrong with my Server Response Format?
v
You can continue this conversation by mentioning me in the message.
@Michael P Your server response format seems to be correct according to the VAPI format you've described. The JSON response includes a "results" array with an object that contains a "result" key, which holds the availability status (
true
or
false
). If the AI assistant is reporting an issue, the problem might not be with the response format itself, but rather with one of the following: 1. The AI assistant might not be receiving the response due to a network or communication issue. 2. There could be an error in the way the AI assistant is parsing or interpreting the response. 3. The AI assistant might be expecting additional information in the response that is not being provided. 4. The Google auth token might be invalid or expired, causing the calendar check to fail. To further diagnose the issue, you may need to check the logs or error messages from the AI assistant's side to see why it's having problems checking availability. If you have access to the AI assistant's code or configuration, verify that it's correctly handling the JSON response from your tool. If the issue persists, please ask support for more info on this.
m
@Vapi The token is correct and I verified that the server response format contains "true", so the lookup worked properly. Could it be my prompting? This is what I used (note, this is just a snippet): "To check Michael's availablility, use the
check_availability
tool and call it with the token ({{token}}), a start datetime (start), and an end datetime (end) in ISO 8601 format. " Should I be specifying anything about the return structure? Note the token is a dynamic variable and I have confirmed that it is correct, so it's not part of the problem. The problem is specifically in the return structure.
v
@Michael P Based on the snippet you've provided, your prompting seems to be clear in terms of what parameters to pass to the
check_availability
tool. However, if the AI assistant is having trouble with the return structure, it might be expecting a different format or additional information. In your server response, you're returning a JSON object with a "results" array that contains an object with a "result" key. If the AI assistant is not recognizing this structure, you might need to adjust the response to match the expected format of the AI assistant. Here are a few things you could consider specifying or checking: 1. Ensure that the AI assistant is expecting the "results" array to contain an object with a "result" key. 2. Check if the AI assistant requires the "result" key to be nested within another object or expects a different key name. 3. Verify if the AI assistant needs any additional metadata in the response, such as a status code or message. 4. Confirm that the AI assistant is correctly parsing the JSON response and that there are no issues with data types (e.g., expecting a string "true" instead of a boolean
true
). If you have access to the documentation or schema that the AI assistant is using to parse the response, review it to ensure your server's response structure aligns with those expectations. If the problem persists, you may need to consult the support or documentation for the AI assistant to determine the exact expected format.
s
@Michael P call id please.
m
@Shubham Bajaj I just figured this out. User error. I was returning the string "true" but if I return True it works. Going to mark this one as solved. Thanks everyone!
k
@Michael P im facing the same problem for the clients especially after moving from functions to tools. can you share the return data we should pass to vapi
s
please create a new discord support ticket.
2 Views