https://retellai.com/?utm_source=discord&utm_medium=seo logo
Hi <@1145576664366055464> can you help us setup ...
# ❓・ai-evy-support
u
Hi @AI Evy can you help us setup web call integration
a
Thanks for tagging me @utkarsh_retell_48744. I'll look through relevant sources and get back to you shortly.
----------------------------- **While I generate an answer, here are some sources that might be helpful**: * [Setup WebSocket Server]() * [Integrate LLM]() * [Quick Start]() * [Custom LLM Overview]() -----------------------------
### Answer Here's how to set up web call integration: 1. First, install the Retell Web SDK [(1)]() :
Copy code
javascript
npm install retell-client-js-sdk
2. Set up the SDK class:
Copy code
javascript
import { RetellWebClient } from "retell-client-js-sdk";

const retellWebClient = new RetellWebClient();
3. Call create-web-call API from your server to get an access token. Note: The token expires in 30 seconds if unused. 4. Start the call with the access token:
Copy code
javascript
await retellWebClient.startCall({
  accessToken: createCallResponse.access_token,
});
5. You can listen to events for real-time updates:
Copy code
javascript
retellWebClient.on("call_started", () => {
  console.log("call started");
});

retellWebClient.on("call_ended", () => {
  console.log("call ended");
  setIsCallActive(false);
});

retellWebClient.on("agent_start_talking", () => {
  console.log("agent_start_talking");
});

retellWebClient.on("agent_stop_talking", () => {
  console.log("agent_stop_talking");
});

retellWebClient.on("update", (update) => {
  // console.log(update);
});

retellWebClient.on("error", (error) => {
  console.error("An error occurred:", error);
  retellWebClient.stopCall();
});
6. To end the call:
Copy code
javascript
retellWebClient.stopCall();
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.