Tool got called twice
# support
s
When I call my tool to book an appointment, sometimes it calls the function twice which causes an error because on the second run, the assistant says that the slot is taken even though it just booked the appointment. 5931250e-c82c-4e09-b9d9-752b186c1fd9 01:14
v
@Saien It sounds like there might be an issue with the function being triggered multiple times, which could be due to multiple reasons such as a user interface glitch, a problem with the function's idempotency, or an issue with the way the function is being called. To address this, you can implement a check within your server logic to ensure that once an appointment slot is booked, subsequent requests with the same parameters are ignored or handled differently. This could involve checking if the slot is already taken and, if so, returning a message that the appointment has already been booked. Additionally, you may want to review the code that triggers the function call to ensure it's not being called more than once per user action. If you're using a front-end framework or library, make sure that event handlers are not attached multiple times. If you need further assistance with debugging this issue, please provide more details about how the function is being called or ask support for more info on this.
You can continue this conversation by mentioning me in the message.
s
@User
s
@Saien can you join the vapi office hour and ask this question over there?
s
Unfortunately I can’t since I’m AFK right now
s
@Shubham Bajaj can you take a look into this issue.
s
it;s one of the chance model called the tool twice there is no specific answer to it.
s
So it's just something I have to deal with? It just happened again now
It's not something that is okay because it ruins the functionality of my appointment setter.
7b5fbd3b-38ea-4cdf-b797-7c1bc3720286 at 01:15
s
lemme check
s
I appreciate it
s
the issue is related to the prompt, your making bot jumpes back and forth b/w steps and in b..w it's calling the tool twice as per the flow/prompt.
Adding the
(BUT ONLY CALL IT ONCE)
wont work.
let me know how it goes.
s
Okay thank you I'll let you know
It's calling the function twice basically every time I test it now. This can't be a prompting issue because it hardly occurred at all yesterday and even earlier today. The only time it ever calls it twice is step 1 of my booking procedure but step 3 never fails
It genuinely can't be my prompt that's the issue. It fails every time now
28ac19db-5be8-4d1f-9d02-1bf2cdff4e10
Maybe I need to update the tool description so that it doesn't get called unless it is explicitly called
Seems like I solved the issue. I had to add in a messages array to the tool. Not sure why the UI for creating a tool doesn't include this
s
can you describe and share loom video of it.
s
A loom wouldn't really be necessary. All I did was update the tool to include this messages array (which it previously didn't have).
Copy code
"messages": [
    {
      "type": "request-start",
      "content": "One sec"
    },
    {
      "type": "request-failed",
      "content": "Unfortuntately I wasn't able to view our calendar's availability due to a server error."
    }
  ],
5 Views