retell_create_web_call
Start a web call session with an AI agent by generating a unique call ID and access token for WebRTC connection setup.
Instructions
Create a new web call session. Returns a call ID and access token for establishing a WebRTC connection.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| agent_id | Yes | The agent ID to use for the web call | |
| metadata | No | Optional: Custom metadata to attach to the call | |
| retell_llm_dynamic_variables | No | Optional: Dynamic variables to pass to the LLM |
Implementation Reference
- src/index.ts:92-113 (schema)Tool definition including name, description, and input schema for validating parameters like agent_id, metadata, and dynamic variables.{ name: "retell_create_web_call", description: "Create a new web call session. Returns a call ID and access token for establishing a WebRTC connection.", inputSchema: { type: "object", properties: { agent_id: { type: "string", description: "The agent ID to use for the web call" }, metadata: { type: "object", description: "Optional: Custom metadata to attach to the call" }, retell_llm_dynamic_variables: { type: "object", description: "Optional: Dynamic variables to pass to the LLM" } }, required: ["agent_id"] } },
- src/index.ts:1125-1126 (handler)Handler case within executeTool switch statement that executes the tool by calling retellRequest to POST to the Retell API /v2/create-web-call endpoint with provided arguments.case "retell_create_web_call": return retellRequest("/v2/create-web-call", "POST", args);
- src/index.ts:23-57 (helper)Generic helper function retellRequest that makes authenticated HTTP requests to the Retell API, used by all Retell tools including retell_create_web_call.async function retellRequest( endpoint: string, method: string = "GET", body?: Record<string, unknown> ): Promise<unknown> { const apiKey = getApiKey(); const headers: Record<string, string> = { "Authorization": `Bearer ${apiKey}`, "Content-Type": "application/json", }; const options: RequestInit = { method, headers, }; if (body && method !== "GET") { options.body = JSON.stringify(body); } const response = await fetch(`${RETELL_API_BASE}${endpoint}`, options); if (!response.ok) { const errorText = await response.text(); throw new Error(`Retell API error (${response.status}): ${errorText}`); } // Handle 204 No Content if (response.status === 204) { return { success: true }; } return response.json(); }
- src/index.ts:1283-1285 (registration)Registration of tool listing handler that returns the tools array containing retell_create_web_call.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });
- src/index.ts:1287-1313 (registration)Registration of the general tool execution handler (CallToolRequestSchema) that dispatches to executeTool based on tool name, handling retell_create_web_call.// Register tool execution handler server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; try { const result = await executeTool(name, args as Record<string, unknown>); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Error: ${errorMessage}`, }, ], isError: true, }; } });