https://retellai.com/?utm_source=discord&utm_medium=seo logo
how pass mocked functions on create-web-call endpo...
# ❓・ai-evy-support
n
@AI Evy how pass mocked functions on create-web-call endpoint?
a
Thanks for tagging me @Nicolas. I'll look through relevant sources and get back to you shortly.
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
### Answer To pass mocked functions on the create-web-call endpoint, you need to understand that function calling in Retell AI works through the LLM WebSocket connection, not directly through the create-web-call endpoint parameters. [(1) ]() [(2) ]() The create-web-call endpoint initiates the call and establishes the WebSocket connection to your server. [(3) ]() Once connected, your server receives events through the LLM WebSocket and can respond with function calls. [(1) ]() For function calling integration, you define functions in your LLM client and handle them through the WebSocket protocol: [(2) ]()
Copy code
typescript
export interface FunctionCall {
 id: string;
 funcName: string;
 arguments: Record<string, any>;
 result?: string;
}
The function definitions are prepared in your server-side code:
Copy code
typescript
private PrepareFunctions() : ChatCompletionsFunctionToolDefinition[] {
 let functions: ChatCompletionsFunctionToolDefinition[] = [{
 type: "function",
 function: {
 name: "end_call",
 description: "End the call only when user explicitly requests it.",
 parameters: {
 type: "object",
 properties: {
 message: {
 type: "string",
For a simpler approach without custom LLM integration, you can use Code Tool, which lets you write JavaScript code directly in the dashboard that executes during calls. [(4) ]() This doesn't require mocking functions through the API endpoint—instead, you configure tools in your agent settings.
a
Thanks for the follow-up, @Nicolas. I'll get back to you soon.
### Answer To reproduce custom function mocks on the web-call endpoint, you need to understand that custom functions are configured at the agent level, not passed through the web-call endpoint itself. [(1) ]() [(2) ]() Custom functions are set up in the dashboard under the agent's "Functions" section. [(1) ]() Once configured, they're automatically available when you create a web call using that agent. Here's how the flow works: 1. Configure custom functions in your agent settings [(2) ]() Add custom functions through the dashboard by: - Clicking "+ Add" in the tools section and selecting "Custom Function" - Defining the function name, description, and parameters - Setting your endpoint URL where Retell will send POST requests 2. Create the web call When you call the create-web-call endpoint, the agent you specify already has the custom functions configured. The functions are invoked during the call based on the LLM's decisions. [(1) ]() 3. Handle function execution Retell sends requests to your specified endpoint with this structure: [(2) ]()
Copy code
json
{
 "name": "function_name",
 "call": { /* call object */ },
 "args": { /* function arguments */ }
}
For testing/mocking: If you want to mock custom functions for testing, set up a mock server endpoint that: - Accepts POST requests from Retell - Returns mock responses in string, JSON, or other formats - Verifies the
X-Retell-Signature
header if needed The custom functions themselves aren't "passed" to the web-call endpoint—they're pre-configured in your agent and automatically available during any call using that agent. [(1) ]() [(2) ]()
​ To learn more, see the sources I considered: [[1] Function Calling Overview](https://docs.retellai.com/build/single-multi-prompt/function-calling) [[2] Integrate any system with custom function](https://docs.retellai.com/build/single-multi-prompt/custom-function) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.