hotfudge99
08/20/2025, 2:59 PMAI Evy
08/20/2025, 3:00 PMAI Evy
08/20/2025, 3:00 PMcall_ended event is the correct place to implement your "interview complete" state . The Retell Web SDK provides several events for handling call lifecycle:
javascript
retellWebClient.on("call_started", () => {
console.log("call started") ;
}) ;
retellWebClient.on("call_ended", () => {
console.log("call ended") ;
setIsCallActive(false) ;
}) ;
For cleanup, you can stop the call using:
javascript
retellWebClient.stopCall() ;
The SDK also provides error handling through the error event:
javascript
retellWebClient.on("error", (error) => {
console.error("An error occurred:", error) ;
// Stop the call
retellWebClient.stopCall() ;
}) ;
The documentation shows that the call_ended event fires regardless of how the call ends - whether through normal completion, user hangup, or errors . For error scenarios, you should handle both the error event and the subsequent call_ended event .
The SDK provides additional events for UI animations:
javascript
// When agent starts talking for the utterance
// useful for animation
retellWebClient.on("agent_start_talking", () => {
console.log("agent_start_talking") ;
}) ;
// When agent is done talking for the utterance
// useful for animation
retellWebClient.on("agent_stop_talking", () => {
console.log("agent_stop_talking") ;
}) ;
Based on the available documentation, the recommended pattern is to use the call_ended event for your UI transition and ensure you call stopCall() in error scenarios .AI Evy
08/20/2025, 3:00 PMAI Evy
08/20/2025, 3:00 PM