> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes. # execute > Execute the function with the given arguments. [ref-functionresult]: /docs/server-sdks/reference/typescript/agents/function-result Execute the function with the given arguments. Calls the handler and normalizes the return value into a serialized result dictionary. ## **Parameters** **`args`** `Record` — required Parsed arguments for the function, matching the parameter schema. --- **`rawData`** `Record` Full raw request data including `global_data`, `call_id`, `caller_id_number`, `meta_data`, and `ai_session_id`. --- ## **Returns** `Promise>` -- The function result as a dictionary (from `FunctionResult.toDict()`). If the handler throws an exception, returns a generic error message rather than exposing internal details. > **Note** > > The handler can return a [`FunctionResult`][ref-functionresult], an object with a `"response"` key, > or a plain string. All formats are normalized to a result dictionary. ## **Example** ```typescript {19} import { SwaigFunction, FunctionResult } from '@signalwire/sdk'; const func = new SwaigFunction({ name: "lookup_account", handler: async (args, rawData) => { const accountId = (args.account_id as string) ?? ""; return new FunctionResult(`Account ${accountId} is active.`); }, description: "Look up account status", parameters: { type: "object", properties: { account_id: { type: "string", description: "Account ID" }, }, required: ["account_id"], }, }); const result = await func.execute({ account_id: "12345" }); console.log(result); // { response: "Account 12345 is active." } ``` > Execute the function with the given arguments.