How can you immediately end a call?
# support
v
I've been trying to use vapi.stop() as recommended in the docs, but it doesn't seem to end the call. Is the stop() function the only intended way to end the call after a user action (like button click), or is there something that possibly needs to be set for the assistant?
v
Hi @Vivek, I'm an AI assistant for Vapi. While a team member reviews this question, I'll look through relevant sources and see if I can provide suggestions. Please tag @Vapi Support with any follow-up questions.
----------------------------- **While I generate an answer, here are some sources that might be helpful**: * [Voice Widget Example]() * [Phone Numbers]() * [Silent Text Messages Logging]() * [Assistants]() -----------------------------
### Answer The
vapi.stop()
function you mentioned isn't directly referenced in the provided documentation, so it's possible that there's a misunderstanding or a different function or setting might be required to end a call immediately after a user action. For assistants, settings such as enabling the
endCallFunctionEnabled
property might be relevant for allowing an assistant to end a call, but without direct reference to
vapi.stop()
, I recommend checking the assistant's configuration and the documentation on ending calls or managing call flow for further guidance [(1)]() . If this doesn't resolve your issue, it might be a specific case not covered in the provided excerpts, and consulting the full Vapi documentation or reaching out to support directly through their official channels might offer a resolution.
j
Yes it should end the call! ensure you're stopping the same instance of the vapi client 🙂
v
hey @jordan, in my code I've been calling vapi.stop(), and it doesn't seem to end the call, and instead the call is disrupted about a minute later with a CORS issue. I can share all the warnings and error statements I have if that's relevant
In addition, when I start the call I get this error. Would you know if that is possibly relevant to my issue?
I am using Reactjs if that may be related to the issue at all. I recreated the pizza example on the docs, but still found the same error.
v
Got it. Tagging @User for additional help.
j
Can I see where you're instantiating the client, starting and stopping the call?
v
yea let me send a picture of my code. I can also hop on a call with you sometime today if you're free too
I've also already verified that the API key from my env file does work, so that shouldn't be a problem
v
Got it. Tagging @User for additional help.
v
Actually, I think I understand the problem, so I'll try fix it. I'll let you know if I'm still running into the issue in a little bit
I was able to solve this problem. Thanks for all the support
v
Glad I could be helpful. Feel free to create a new thread with any new questions you may have.
a
quick question @Vivek how did you end up being able to fix it?
Would you mind sharing please ❤️
i am not sure hwy
s
@Amulya Parmar can you check your console logs?
a
its odd, I have been checking the console logs but they are not helpful, it seems like it comes down to my states really
it is so weird
i created a component so you can see it
@Sahil basically whappens is as soon as I try changing state it gets buggy
if i uncomment th ecode above it stops working
but it makes no sense
also i am in nextjs 14
btw the component above works, but as soon as I change any state on the event hook it stops workign
this may be a bug on nextjs apps
@Sahil , quick question have you been able to replicate the bug?
s
I haven’t tried yet. I will try in few hours and I will let you know
a
Sahil also to make your life easier @Sahil here is a codesandbox that replicates the error. I have been able to replicate the error on entirely different nextjs project https://codesandbox.io/p/devbox/gemini-hackathon-builders-tyg-forked-ljpz6v Check the Vapi/VapiButtonTYG file for the Vapi code you can see that some basic state inside the hooks changes prevent someone from callling vapi.stop if you comment all the state changes on event handlers it works
but obviously someone might need to make those state changes
a
understood, so is it a nextjs problem @Sahil ?
is there a way for su to make it wokr in nextjs too?
that is what i am trying to use it, and it would be tough to switch out the entire project
s
You can ask this question on Office Hours https://discord.gg/PZPCrNPA?event=1243039687740887090
a
Understood! and for context, you saw the nextjs problem right?
s
Yup. I did but, I need to check properly to figure out what is the exact issue. When I get the time I will look into it.
24 Views