https://retellai.com/?utm_source=discord&utm_medium=seo logo
Hi <@1145576664366055464> help me set up web call ...
# ❓・ai-evy-support
c
Hi @AI Evy help me set up web call from python flask and js and html frontend
a
Thanks for tagging me @cagrik_8. 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**: * [Migration Guide]() * [Create Web Call]() * [Web Call]() * [SDK]() -----------------------------
### Answer Backend Setup (Python) First, install the Python SDK [(1)]() :
Copy code
bash
pip install retell-sdk
Initialize the client:
Copy code
python
from retell import Retell

retell_client = Retell(
    # Find the key in dashboard
    api_key="YOUR_API_KEY",
)
Frontend Setup (JavaScript) Install the Retell Web SDK [(2)]() :
Copy code
bash
npm install retell-client-js-sdk
Set up the SDK class:
Copy code
javascript
import { RetellWebClient } from "retell-client-js-sdk";

const retellWebClient = new RetellWebClient();
Starting the Call After getting the access token from your backend, start the call:
Copy code
javascript
await retellWebClient.startCall({
  accessToken: createCallResponse.access_token,
});
You can also configure additional options:
Copy code
javascript
await retellWebClient.startCall({
  accessToken: createCallResponse.access_token,
  sampleRate: 24000, // (Optional) set sample rate of the audio capture and playback
  // (Optional) device id of the mic.
  captureDeviceId: "default",
  // (Optional) device id of the speaker
  playbackDeviceId: "0ec1807fd0fe6e51b990660ec4e2ebb78sdfcba51e279815d00c423ce03407ff",
  // (Optional) Whether to emit "audio" events that contain raw pcm audio bytes represented by Float32Array
  emitRawAudioSamples: false,
});
Event Listeners Set up event listeners for call status:
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);
  // Stop the call
  retellWebClient.stopCall();
});
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
c
Help me run this code step by step with terminal comands and everything @AI Evy
a
Thanks for the follow-up, @cagrik_8. I'll get back to you soon.
----------------------------- **While I generate an answer, here are some sources that might be helpful**: * [LLM WebSocket]() * [Web Call]() * [Audio Basics]() * [changelog]() -----------------------------
### Answer Step 1: Install Python SDK
Copy code
bash
pip install retell-sdk
[(1)]() Step 2: Install Frontend SDK
Copy code
bash
npm install retell-client-js-sdk
[(2)]() Step 3: Set up Python backend server with the following code:
Copy code
python
from retell import Retell

retell_client = Retell(
    # Find the key in dashboard
    api_key="YOUR_API_KEY",
)
[(1)]() Step 4: Set up Frontend JavaScript with:
Copy code
javascript
import { RetellWebClient } from "retell-client-js-sdk";

const retellWebClient = new RetellWebClient();
[(2)]() Step 5: Set up event listeners:
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);
  // Stop the call
  retellWebClient.stopCall();
});
For complete working examples and troubleshooting, you can check out the React demo repository [(3)]() . Based on the Discord discussions, there may be additional configurations needed for a fully working implementation. I recommend checking out these resources for more detailed implementation help: - [Contact Sales]() - [Discord]() - [https://github.com/RetellAI/]()
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
c
Please write me code for everything such as howt o connect the backend with frotnedn and run things @AI Evy
a
Thanks for the follow-up, @cagrik_8. I'll get back to you soon.
----------------------------- **While I generate an answer, here are some sources that might be helpful**: * [LLM WebSocket]() * [Custom LLM Overview]() * [Web Call]() * [SDK]() -----------------------------
### Answer Based on the available documentation, I cannot provide a complete end-to-end implementation with Flask backend integration code since this is not explicitly shown in the information sources. However, what we do know from the docs is that: 1. You need both a backend and frontend implementation [(1)]() 2. The frontend needs to make a backend request to get call information before starting the WebSocket connection To avoid providing potentially incorrect or unsupported code, I recommend: 1. Check out the official example repositories: - [Node Demo Repository]() - [Python Demo Repository]() [(2)]() 2. Get additional implementation help through: - [Contact Sales]() - [Discord]() - [https://github.com/RetellAI/]() This way you can see complete working examples rather than potentially incorrect partial implementations.
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.