
Creating a Function tool
Create the tool
You can add, or create a Function tool directly from within a playbook.

You can also create Function tools from within a workflow using the Function step, or from the tools CMS tab.
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.
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.
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.
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.
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.