When we call the function handleStopVapi when its ...
# support
d
This is the method we are using start the connect and stop the connection: useEffect(() => { try { vapiRef.current = new Vapi('api-key'); vapiRef.current.on('message', (message) => { }); vapiRef.current.on('speech-start', () => { }); vapiRef.current.on('speech-end', () => { // setGhostVolume(0); }); vapiRef.current.on('call-start', () => { }); vapiRef.current.on('call-end', () => { }); vapiRef.current.on('volume-level', (volume) => {}); vapiRef.current.on('error', (e) => { console.error(e); }); } catch (e) { console.log('error when mounting vapi', e.message); } }, []); const handleStartVapi = () => { try { vapiRef.current.start(vapiConfig); } catch(e) { console.error(e) } } const handleStopVapi = () => { try { vapiRef.current.stop() } catch(e) { console.error(e) } }
v
message has been deleted
@DomnulZeu It looks like you've implemented a solid structure for managing the lifecycle of your Vapi connection within a React component using the
useEffect
hook for setup and cleanup, and separate handlers for starting and stopping the Vapi connection. Your
useEffect
hook is set up to initialize the Vapi instance and define various event handlers for different events such as
message
,
speech-start
,
speech-end
,
call-start
,
call-end
,
volume-level
, and
error
. This is a good practice as it helps you manage the state and behavior of your application in response to these events. The
handleStartVapi
and
handleStopVapi
functions are straightforward and are designed to start and stop the Vapi connection, respectively. It's good that you've included try-catch blocks to handle any potential errors that might occur during these operations. If you have any specific questions or need further assistance with your Vapi implementation, feel free to ask!
You can continue this conversation by mentioning me in the message.
Got it. Tagging @User for additional help.
m
@User The connection is still on, in background stop doesn't work
d
@Sahil
s
Looks like you guys have quite a lot of questions. How about we schedule a 15-minute call and address those issues?
d
Ok
@Sahil this is till not fixed
s
I have added to our list. I will notify you once it is fixed.