https://retellai.com/?utm_source=discord&utm_medium=seo logo
I want to implement the WebSockets API to handle c...
# ❓・ai-evy-support
d
@AI Evy I want to implement the WebSockets API to handle custom tools of my agent directly in my code, but I can not seem to find it and also there is no place to add the webssocket webhook url any more in my agent
a
Thanks for tagging me @danielgarcia_85844. I'll look through relevant sources and get back to you shortly.
### Answer Based on the available sources, I can help you understand how to implement the WebSocket API for custom tools in Retell AI. The LLM WebSocket API is designed to connect directly to your server where you handle custom LLM responses and tool calls [(1) ]() . The WebSocket endpoint follows this format:
{your-server-websocket-endpoint}/{call_id}
. For handling custom tools (function calls) , you'll need to implement tool call events in your WebSocket server . The system supports: - **Tool Call Invocation Event**: To send tool call invocations to Retell - **Tool Call Result Event**: To send tool call results back to Retell Here's how the tool calling works in the WebSocket:
Copy code
typescript
// Tool Call Invocation Event structure
{
  "response_type": "tool_call_invocation",
  "tool_call_id": "string",
  "name": "string", 
  "arguments": "boolean"
}

// Tool Call Result Event structure  
{
  "response_type": "tool_call_result",
  "tool_call_id": "string",
  "content": "string"
}
To set up your WebSocket server, you need to create an endpoint that handles the WebSocket connection [(2) ]() . The protocol requires your server to send the first message and handle live transcripts from Retell . If you're having trouble finding where to add the WebSocket URL in your agent configuration, this might be related to recent dashboard changes mentioned in the changelog [(3) ]() . The dashboard underwent a complete overhaul with a more user-friendly agent builder . For integrating third-party APIs through custom functions, you can define custom functions, link them to webhooks, and set your webhook to receive requests and call APIs as needed [(4) ]() .
​ To learn more, see the sources I considered: [[1] LLM WebSocket](https://docs.retellai.com/api-references/llm-websocket) [[2] Setup WebSocket Server](https://docs.retellai.com/integrate-llm/setup-websocket-server) [[3] Platform Changelogs | Retell AI](https://www.retellai.com/changelog) [[4] Discord message from @manny_40662 on 2024-11-14](https://discord.com/channels/1186424376300679209/1294891368505937952/1306723741224538213) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
d
thi is for outbound calling so not sure if we are doing this in the right direction @AI Evy
a
Thanks for the feedback, glad I was helpful.