function keeps triggering webhook
# support
h
I have a book appointment function in vapi. it triggers a webhook in make that books them in or says that the time isnt available. whenever the time isnt available it triggers the webhook again
v
Hi @howwy, 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**: * [Server URLs]() * [Outbound Sales Example]() * [Glossary]() * [Function Calling]() -----------------------------
### Answer It seems like the behavior you're experiencing with the "book appointment" function might be related to how the function is configured within your Vapi assistant. If the function continues to trigger the webhook even when the time is not available, there might be a loop or a recurrent trigger mechanism set up unintentionally. You can control how and when functions are triggered by setting conditions within the assistant's configuration. Ensure that the function calling mechanism is configured to handle failure responses appropriately and doesn’t re-trigger under the same conditions unless specified. Here's a general approach to modify the function calling condition: 1. Check the function's trigger conditions within your assistant's configuration. Make sure it is set to trigger only when the specific conditions are met. 2. Implement logic on your server endpoint to handle different responses. For instance, modify the response handling logic so that it does not re-trigger the function unnecessarily when the "time not available" message is received. 3. Utilize the
result
property to communicate the outcome back to the assistant, allowing it to handle the flow correctly based on the response [(1)]() . Here is an example of how you might configure the server response to handle failure:
Copy code
json
{
  "result": "The appointment time is unavailable, please try another time."
}
This example ensures that the function calling mechanism in Vapi gets a clear response indicating that the time slot isn't available, which should prevent it from triggering the webhook again under the same circumstances. For more detailed guidance on handling function calls and designing robust error handling within your Vapi assistant, you can refer to the function calling documentation.
h
i already have a result thing. it says the time isnt available and then also sends available slots
v
Got it. Tagging @User for additional help.
h
#Booking Rules Our active hours are only between 8 am and 7pm EST Time slots are 90 minutes each Maximum set out date for appointments is 3 days Run the ‘bookAppointment’ function when the customer says the date and time they want If the ‘bookAppointment’ function says the slot is no longer available YOU MUST GIVE times close that are available. Example: Customer: ”Tomorrow at 10:30” Function says it’s not available You: “We have slots available at 9 am or 12 pm”
5cb83bad-5c0b-4f9e-ada4-6eb5aa6c5322 b3cf9f80-637d-4b06-88e4-d25d026e5380
s
You are not returning the response properly in the required format.
check this docs
h
ok