https://retellai.com/?utm_source=discord&utm_medium=seo logo
We’re building a custom web interview page using t...
# ❓・ai-evy-support
h
@AI Evy We’re building a custom web interview page using the retell-client-js-sdk@2. Our flow is: User clicks Start Interview → we fetch an access token from our backend. We call retellWebClient.startCall({ accessToken }). During the call, the button animates with a “sound wave” animation. When the call ends, we want the button and animation to disappear, and the page to display a final message like “Interview complete. Thank you for your feedback.” Questions: Is the onCallEnded callback the correct place to implement this “interview complete” state? Are there any best practices or required cleanup steps (e.g. calling a retellWebClient method, releasing media streams, handling errors) after a call ends? Do you have documentation or code samples that show the recommended way to handle the UI transition once a call is finished? Is there any difference in handling depending on whether the call ends normally vs. due to a network error or participant hang-up? We want to make sure our page transitions gracefully and that resources are cleaned up properly.
a
Thanks for tagging me @hotfudge99. I'll look through relevant sources and get back to you shortly.
### Answer [(1) ]() Yes, the
call_ended
event is the correct place to implement your "interview complete" state . The Retell Web SDK provides several events for handling call lifecycle:
Copy code
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:
Copy code
javascript
retellWebClient.stopCall() ;
The SDK also provides error handling through the error event:
Copy code
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:
Copy code
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 .
​ To learn more, see the sources I considered: [[1] Connect to web call](https://docs.retellai.com/deploy/web-call) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.