> For the complete documentation index, see [llms.txt](https://docs.borndigital.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.borndigital.ai/digital-agent/conversation-flow/nodes-explained/function-node.md).

# FUNCTION node

Use the Function node to run tools, call back-end systems and set or reset variables in the background.

The Function node does work in the background: it runs **tools** – smart functions that extract data, call APIs, check opening hours and much more – and sets or resets **variables**. The customer doesn't see anything; the flow continues straight to the next node.

<figure><img src="https://4261467870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6iQTvxgRZRwPS1NgIGEb%2Fuploads%2FWGnOczYj0EtuE6F7SWyZ%2Fnodes2-fnc-editor.png?alt=media&amp;token=330abb77-59e9-4ac2-9a5c-9dff24a7c0d9" alt="The Function node editor"><figcaption><p>A Function node with one tool, two variables and a reset</p></figcaption></figure>

The editor has these sections:

* **Tools** – smart functions to run.
* **Variables** – values to set.
* **Reset variables** – variables and tools to clear.
* **Configuration** – when the function runs.
* **Next** – the node the conversation continues to.

{% hint style="info" %}
Tools run before variables, and within each section items run from top to bottom. Drag the handle on the right to change the order – a variable can use the result of a tool or of a variable above it.
{% endhint %}

***

## Tools

Click **Add** in **Tools** to open the tool editor.

<figure><img src="https://4261467870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6iQTvxgRZRwPS1NgIGEb%2Fuploads%2Fa0p1W4XEaE5EZDhvWutV%2Fnodes2-fnc-tool-editor.png?alt=media&amp;token=003ffc37-4c6f-4299-99f3-39436aeffcc8" alt="The tool editor"><figcaption><p>Setting up the Check working hours tool</p></figcaption></figure>

1. Type a name in the field at the top. This is the variable that will hold the tool's result, for example `is_billing_open`.
2. In **Name**, pick the tool from the catalogue. Start typing to search by name.
3. Fill in the tool's parameters. If the tool has optional parameters, turn on **Optional parameters** to see them.
4. Click **Save**.

The panel on the right describes the selected tool – what it does, an example of its input and output, and every parameter.

{% hint style="info" %}
Tools for working with dates and times, names, addresses, numbers, e-mails, APIs (**Fetch Url**), language models and more are available. Every tool with its parameters and an example is described in [Tools & smart functions](/digital-agent/tools-reference.md).
{% endhint %}

***

## Variables

Click **Add** in **Variables** to open the variable editor. Enter the variable name and its value.

<figure><img src="https://4261467870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6iQTvxgRZRwPS1NgIGEb%2Fuploads%2Ft4W2T7TgI5kbxIcxNtXj%2Fnodes2-fnc-variable-editor.png?alt=media&amp;token=e02fa3fc-8081-405c-b59e-c8a4f4b8216a" alt="The variable editor"><figcaption><p>The variable editor with the Time toolkit open</p></figcaption></figure>

The value is a Python-style expression:

| Value                                            | Result                                   |
| ------------------------------------------------ | ---------------------------------------- |
| `"VIP"`                                          | The text *VIP* – text must be in quotes. |
| `32`, `True`                                     | A number or a true/false value.          |
| `invoice_amount * 1.2`                           | A calculation using another variable.    |
| `"VIP" if invoice_amount > 1000 else "Standard"` | A value that depends on a condition.     |

The buttons under the editor – **Blocks**, **Convert**, **Text**, **Extract**, **Operator**, **Time**, **Conditions** and **Join** – insert ready-made snippets, for example the current date, a text replacement or a comparison. Use the arrows in the top-right corner to undo and redo changes.

***

## Reset variables

Select the variables and tools whose values should be cleared when the conversation reaches this node – for example to let the customer enter an invoice number again.

***

## Configuration

* **Execute function first** – the flow continues only after this function has finished and every message before this node has been played to the customer.

***

## Next

Choose the node the conversation continues to. Turn on **Dynamic** to take the node's name from a variable.
