alejo8888_48252
08/06/2025, 3:45 AMAI Evy
08/06/2025, 3:45 AMAI Evy
08/06/2025, 3:46 AMjavascript
// install the sdk: <https://docs.retellai.com/get-started/sdk>
import { Retell } from "retell-sdk";
import express, { Request, Response } from "express";
const app = express() ;
app.use(express.json() ) ;
app.post("/webhook", (req: Request, res: Response) => {
const {event, call} = req.body;
switch (event) {
case "call_started":
console.log("Call started event received", call.call_id) ;
break;
case "call_ended":
console.log("Call ended event received", call.call_id) ;
break;
case "call_analyzed":
console.log("Call analyzed event received", call.call_id) ;
break;
default:
console.log("Received an unknown event:", event) ;
}
// Acknowledge the receipt of the event
res.status(204) .send() ;
}) ;
En el ejemplo de configuración de webhook, el endpoint se define como "/webhook" . Para crear tu propio endpoint, necesitas configurar una URL HTTP o HTTPS que pueda aceptar solicitudes webhook con método POST .
Tu endpoint_id sería la URL completa donde tienes configurado tu servidor, por ejemplo: ` o si usas ngrok para pruebas locales: ` .
Para configurar tu endpoint:
1. Crea tu servidor endpoint que pueda aceptar solicitudes POST
2. Despliega tu endpoint usando ngrok o tu propio dominio
3. Registra tu webhook endpoint en el dashboard de Retell AIAI Evy
08/06/2025, 3:46 AMAI Evy
08/06/2025, 3:46 AM