lebacc
10/07/2025, 7:15 PMAI Evy
10/07/2025, 7:15 PMAI Evy
10/07/2025, 7:15 PMbash
npm install retell-client-js-sdk
Step 2: Set up the SDK
javascript
import { RetellWebClient } from "retell-client-js-sdk";
const retellWebClient = new RetellWebClient() ;
Step 3: Get access token from your backend
Your client code should call your server endpoint which internally calls the create web call API to get the access token . The endpoint requires using your Retell API Key, which is why you need to call it from the server instead of client to protect the key .
Step 4: Start the call
javascript
await retellWebClient.startCall({
accessToken: createCallResponse.access_token,
}) ;
Important notes:
- You cannot just paste an access token into HTML - it must be obtained dynamically from your backend
- If you do not start the call within 30s of obtaining the access token, it will be invalidated and the call will be marked with error
- There's a working demo available at that includes both frontend and backend components [(3) ]()
The key issue is that web calls require a proper backend server to generate access tokens securely - you can't just hardcode them in HTML files [(2) ]() [(1) ]() .AI Evy
10/07/2025, 7:15 PMAI Evy
10/07/2025, 7:15 PMlebacc
10/07/2025, 7:17 PMlebacc
10/07/2025, 7:17 PMAI Evy
10/07/2025, 7:17 PMAI Evy
10/07/2025, 7:18 PMretell-client-js-sdk package that contains JavaScript code for handling web calls [(2) ]() .
How to install it:
You need Node.js (a JavaScript runtime) installed on your computer first [(1) ]() . The SDK requires Node.js version 18.10.0 or higher .
Once you have Node.js, you install the SDK using this command in your project folder:
npm i retell-sdk
What this does:
This downloads the Retell AI code package into your project so you can use it in your web application . It's not a standalone program - it's code that becomes part of your web project.
For web calls specifically:
The frontend web JS SDK abstracts away audio complexity for you, capturing user audio in PCM format and sending it to the backend for processing [(3) ]() .
If you're new to web development, you might want to start with the working demo that includes both frontend and backend components, which can help you understand how all the pieces fit together.AI Evy
10/07/2025, 7:18 PMAI Evy
10/07/2025, 7:18 PMlebacc
10/07/2025, 7:20 PMAI Evy
10/07/2025, 7:21 PMAI Evy
10/07/2025, 7:21 PM> prompt, type .exit and press Enter to get back to your normal command prompt
2. Use your system's command prompt/terminal - You need to run npm commands in:
- Windows: Command Prompt or PowerShell
- Mac/Linux: Terminal
3. Navigate to your project folder - Use cd command to go to where you want to create your project
4. Then run the install command - Once you're in the right location with the normal command prompt, run:
npm i retell-sdk
For web calls specifically, you need a different package:
For web calls, you actually need the client-side SDK, which is installed with a different command. The main retell-sdk is for server-side Node.js applications .
What you're trying to do:
Since you mentioned wanting to create web calls in HTML, you'll need to set up a proper web development environment with both frontend and backend components, as web calls require server-side token generation for security .
The key is making sure you're in your regular system terminal/command prompt, not inside the Node.js interactive environment.AI Evy
10/07/2025, 7:21 PMAI Evy
10/07/2025, 7:21 PMlebacc
10/07/2025, 7:23 PMAI Evy
10/07/2025, 7:23 PMAI Evy
10/07/2025, 7:23 PMnpm (Node Package Manager) that you use from your system's command line
Where to run the npm command:
You need to use your system's command prompt/terminal, not the Node.js interactive program:
- **Windows**: Search for "Command Prompt" or "PowerShell" in your Start menu
- **Mac**: Search for "Terminal" in Spotlight
- **Linux**: Open Terminal application
Step-by-step process:
1. Open your system's command prompt/terminal (not Node.js)
2. Navigate to where you want your project using cd command
3. Run the install command:
npm i retell-sdk
[(1) ]()
Why you need Node.js if you don't write commands in it:
Node.js provides the npm tool that downloads and manages JavaScript packages . When you run npm i retell-sdk from your command prompt, it uses Node.js behind the scenes to download the Retell SDK package [(2) ]() .
For web calls specifically:
The Retell Node SDK requires Node.js version 18.10.0 or higher [(1) ]() . This package provides TypeScript support and simplified authentication for integrating with Retell AI .
The key is using your system's regular command line interface, not the Node.js interactive environment.AI Evy
10/07/2025, 7:23 PMAI Evy
10/07/2025, 7:23 PMlebacc
10/07/2025, 7:24 PMAI Evy
10/07/2025, 7:24 PMAI Evy
10/07/2025, 7:25 PMnpm install retell-client-js-sdk
[(1) ]()
For server-side Node.js applications, you would use:
npm i retell-sdk
[(2) ]()
Since you mentioned wanting to create web calls that work in Chrome/Opera, you want the first command: npm install retell-client-js-sdk [(1) ]() .
Next steps after installing:
1. Create a project folder - You might want to create a dedicated folder for your project first
2. Set up the SDK - After installation, you'll use this code:
javascript
import { RetellWebClient } from "retell-client-js-sdk";
const retellWebClient = new RetellWebClient() ;
Important note: As mentioned in our previous discussion, web calls require both frontend and backend components . You can't just create an HTML file with hardcoded access tokens - you need a server to generate access tokens securely .
The access token must be obtained from your server endpoint which internally calls the create web call API, and if you don't start the call within 30 seconds of obtaining the access token, it will be invalidated .
So yes, run npm install retell-client-js-sdk in your current command prompt location!AI Evy
10/07/2025, 7:25 PMAI Evy
10/07/2025, 7:25 PMlebacc
10/07/2025, 7:26 PMnpm fund for details
npm notice
npm notice New patch version of npm available! 11.6.0 -> 11.6.1
npm notice Changelog: https://github.com/npm/cli/releases/tag/v11.6.1
npm notice To update run: npm install -g npm@11.6.1
npm notice
C:\Users\38597> and this is what i got. what nowAI Evy
10/07/2025, 7:26 PMAI Evy
10/07/2025, 7:26 PMretell-client-js-sdk is now installed [(1) ]() .
What you have now:
The SDK is installed in your current directory (C:\Users\38597) , which means you have the Retell Web SDK available for use .
Next steps to create a basic web call setup:
1. Create your project files - You'll need at least an HTML file and a JavaScript file to use the SDK .
2. Set up the SDK in your JavaScript code:
javascript
import { RetellWebClient } from "retell-client-js-sdk";
const retellWebClient = new RetellWebClient() ;
Important reality check:
However, as I mentioned before, you still need a backend server to generate access tokens securely [(2) ]() . You cannot just hardcode access tokens in HTML files because:
- Your client code should call your server endpoint which internally calls create web call to get the access token [(1) ]()
- The endpoint requires using your Retell API Key, which is the reason why you need to call the endpoint from the server instead of client to protect the key from exposing
- If you do not start the call within 30s obtaining the access token, we will invalidate it and the call will be marked with error
Recommended approach:
Since you're new to web development, I'd suggest checking out the open-source demo repositories that show working examples with both frontend and backend components [(3) ]() :
- Node.js backend demo
- React frontend demo using SDK
These demos will show you exactly how to set up both the server-side token generation and client-side web calling functionality.AI Evy
10/07/2025, 7:26 PMAI Evy
10/07/2025, 7:26 PMlebacc
10/07/2025, 7:27 PMAI Evy
10/07/2025, 7:27 PMAI Evy
10/07/2025, 7:28 PMmkdir my-retell-project
2. Press Enter
3. Type: cd my-retell-project
4. Press Enter
Step 2: Create your HTML file
1. Type: notepad index.html
2. Press Enter (this opens Notepad with a new file)
3. In Notepad, type a basic HTML structure
4. Save and close Notepad
Step 3: Create your JavaScript file
1. Type: notepad script.js
2. Press Enter
3. In Notepad, you would put the SDK code:
javascript
import { RetellWebClient } from "retell-client-js-sdk";
const retellWebClient = new RetellWebClient() ;AI Evy
10/07/2025, 7:28 PMAI Evy
10/07/2025, 7:28 PMAI Evy
10/07/2025, 7:28 PMlebacc
10/07/2025, 7:30 PMAI Evy
10/07/2025, 7:30 PMAI Evy
10/07/2025, 7:30 PM.js file, not .html [(1) ]() .
File naming:
1. **HTML file**: Name it index.html
2. **JavaScript file**: Name it something like script.js or main.js
Here's the complete setup:
Step 1: Create your HTML file (index.html) :
html
<!DOCTYPE html>
<html>
<head>
<title>Retell Web Call</title>
</head>
<body>
<button id="startCall">Start Call</button>
<button id="stopCall">Stop Call</button>
<script type="module" src="script.js"></script>
</body>
</html>
Step 2: Create your JavaScript file (script.js) :
javascript
import { RetellWebClient } from "retell-client-js-sdk";
const retellWebClient = new RetellWebClient() ;
Step 3: Add the call functionality:
javascript
await retellWebClient.startCall({
accessToken: createCallResponse.access_token,
}) ;
Step 4: Add stop call functionality:
javascript
retellWebClient.stopCall() ;
Important notes:
- The import statement requires type="module" in your HTML script tag
- You'll need to get the access token from your backend before calling startCall
- The access token must be used within 30 seconds of generation or it will be invalidated
Since you have the backend ready, you just need to connect it to fetch the access token and pass it to the startCall method .AI Evy
10/07/2025, 7:30 PMAI Evy
10/07/2025, 7:30 PMlebacc
10/07/2025, 7:31 PMAI Evy
10/07/2025, 7:31 PMAI Evy
10/07/2025, 7:32 PMscript.js file [(1) ]() . Here's the complete structure:
Your script.js file should look like this:
javascript
import { RetellWebClient } from "retell-client-js-sdk";
const retellWebClient = new RetellWebClient() ;
// Add event listeners for your buttons
document.getElementById('startCall') .addEventListener('click', async () => {
// Get access token from your backend first
const response = await fetch('/your-backend-endpoint') ;
const createCallResponse = await response.json() ;
// Start the call
await retellWebClient.startCall({
accessToken: createCallResponse.access_token,
}) ;
}) ;
document.getElementById('stopCall') .addEventListener('click', () => {
retellWebClient.stopCall() ;
}) ;
Where each part goes:
1. Import and initialization - At the top of script.js
2. Start call functionality - Inside a function that gets triggered when user clicks the start button
3. Stop call functionality - Inside a function that gets triggered when user clicks the stop button
Important notes:
- You need to replace /your-backend-endpoint with the actual URL of your backend that generates access tokens
- The access token must be obtained fresh each time from your backend
- If you do not start the call within 30s of obtaining the access token, it will be invalidated and the call will be marked with error
Optional: Add event listeners for call events:
javascript
retellWebClient.on("call_started", () => {
console.log("call started") ;
}) ;
retellWebClient.on("call_ended", () => {
console.log("call ended") ;
}) ;
retellWebClient.on("error", (error) => {
console.error("An error occurred:", error) ;
retellWebClient.stopCall() ;
}) ;AI Evy
10/07/2025, 7:32 PMAI Evy
10/07/2025, 7:32 PMlebacc
10/07/2025, 7:33 PMAI Evy
10/07/2025, 7:33 PMAI Evy
10/07/2025, 7:33 PMindex.html) *
html
<!DOCTYPE html>
<html>
<head>
<title>Retell Web Call</title>
</head>
<body>
<button id="startCall">Start Call</button>
<button id="stopCall">Stop Call</button>
<script type="module" src="script.js"></script>
</body>
</html>
*2. JavaScript File (script.js) *
javascript
import { RetellWebClient } from "retell-client-js-sdk";
const retellWebClient = new RetellWebClient() ;
// Event listeners for call events
retellWebClient.on("call_started", () => {
console.log("call started") ;
}) ;
retellWebClient.on("call_ended", () => {
console.log("call ended") ;
}) ;
retellWebClient.on("error", (error) => {
console.error("An error occurred:", error) ;
retellWebClient.stopCall() ;
}) ;
// Start call button
document.getElementById('startCall') .addEventListener('click', async () => {
try {
// Get access token from your backend
const response = await fetch('/create-web-call') ;
const createCallResponse = await response.json() ;
// Start the call
await retellWebClient.startCall({
accessToken: createCallResponse.access_token,
}) ;
} catch (error) {
console.error('Failed to start call:', error) ;
}
}) ;
// Stop call button
document.getElementById('stopCall') .addEventListener('click', () => {
retellWebClient.stopCall() ;
}) ;AI Evy
10/07/2025, 7:33 PMnpx http-server
3. **Access your page**: Open ` in your browser
## Critical Points
- Your client code should call your server endpoint which internally calls create web call to get the access token
- If you do not start the call within 30s obtaining the access token, we will invalidate it and the call will be marked with error
- The access token obtained will be used in your frontend client code to start the call
## Working Demo Available
There's a complete working example at the React demo repository that shows both frontend and backend components working together [(6) ]()AI Evy
10/07/2025, 7:33 PMAI Evy
10/07/2025, 7:33 PMlebacc
10/07/2025, 7:36 PMAI Evy
10/07/2025, 7:36 PMAI Evy
10/07/2025, 7:37 PMngrok http <http://localhost:8080>AI Evy
10/07/2025, 7:37 PMnpx http-server isn't working, try:
- Check if Node.js is properly installed
- Try a different port: npx http-server -p 3000
- Use Python's built-in server: python -m http.server 8000
The key issue is that Retell web calls require both frontend and backend components working together - something JSFiddle cannot provide [(1) ]() .AI Evy
10/07/2025, 7:37 PMAI Evy
10/07/2025, 7:37 PMlebacc
10/08/2025, 4:30 PMAI Evy
10/08/2025, 4:30 PMAI Evy
10/08/2025, 4:31 PMmkdir retell-web-call-project
cd retell-web-call-project
npm init -y
## Step 2: Install Required Packages
Frontend SDK:
npm install retell-client-js-sdk
Backend SDK:
npm install retell-sdk
## Step 3: Create Backend Server (server.js)
javascript
import Retell from 'retell-sdk';
const client = new Retell({
apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const webCallResponse = await client.call.createWebCall({ agent_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD' }) ;
console.log(webCallResponse.agent_id) ;
[(2) ]()
## Step 4: Create Frontend Files
HTML file (index.html) :
html
<!DOCTYPE html>
<html>
<head>
<title>Retell Web Call</title>
</head>
<body>
<button id="startCall">Start Call</button>
<button id="stopCall">Stop Call</button>
<script type="module" src="script.js"></script>
</body>
</html>
JavaScript file (script.js) :
javascript
import { RetellWebClient } from "retell-client-js-sdk";
const retellWebClient = new RetellWebClient() ;AI Evy
10/08/2025, 4:31 PMjavascript
await retellWebClient.startCall({
accessToken: createCallResponse.access_token,
}) ;
Add stop functionality:
javascript
retellWebClient.stopCall() ;
Add event listeners:
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() ;
}) ;
## Step 5: Run Your Application
1. Start your backend server (to generate access tokens)
2. Serve your frontend files using:
npx http-server
3. Open browser to `
## Critical Requirements
- Your client code should call your server endpoint which internally calls create web call to get the access token
- The endpoint requires using your Retell API Key, which is the reason why you need to call the endpoint from the server instead of client to protect the key from exposing
- If you do not start the call within 30s obtaining the access token, we will invalidate it and the call will be marked with error
## Complete Working Example Structure
Your project should have these files:
- package.json (created by npm init)
- server.js (backend to generate tokens)
- index.html (frontend interface)
- script.js (frontend SDK implementation)
The access token obtained will be used in your frontend client code to start the call .AI Evy
10/08/2025, 4:31 PMAI Evy
10/08/2025, 4:31 PM