Skip to main content
Fucntion Tool Docs 1 The Function tool lets your agent run custom JavaScript mid-conversation. Use it for data transformation, calculations, formatting, or any lightweight processing that doesn’t require an external API call.

Creating a Function tool

1

Create the tool

You can add, or create a Function tool directly from within a playbook.Function Playbook Docs
You can also create Function tools from within a workflow using the Function step, or from the tools CMS tab.
2

Define input variables

Add the variables your function needs as inputs. These are passed in by a playbook or a Function step and are accessible inside your code. Add a description to each so the agent knows what to pass.
3

Write your function

Write your JavaScript in the code editor. Your input variables are available directly by name. Return your output by setting the output variable values — these are passed back to the conversation.
4

Define output variables

Add output variables for any values your function should return to the agent. These are available in the conversation after the function runs.
5

Test the function

Click Run in the top right corner to test. Click Variables to enter test values for your inputs, then Run to execute. The output panel shows your returned values and any console logs.

Using the Function tool

There are two ways to use a Function tool:

In a playbook

Add the Function tool to a playbook’s Tools editor. The agent calls it autonomously when the conversation requires it — based on your playbook instructions and the tool’s name and description. Function Playbook Docs For example, a “Calculate Shipping Cost” function added to an order playbook — the agent passes in the order weight and destination, runs the calculation, and uses the result in its response. Give the tool a clear name and description so the agent knows what it does and when to use it.

In a workflow

Drag a Function step onto the canvas and select the Function tool you want to run. Input variables are mapped explicitly in the step config — the function runs at that point in the flow every time. Use this when the logic is part of a fixed process — for example, always formatting a date before displaying it, or always calculating a total before confirming an order. Functions Step Docs