> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hubtalk.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# 07. Function and tools

> Two ways to reach an external system and how to handle a failure.

# External systems: Function and tools

> [!NOTE]
>
> **Module goal:** call a CRM in two different ways and understand when each one fits.

There are two ways to reach an external system, and the difference between them is **who decides it is time to go**.

| | Function node | Tool on a Conversation node |
| - | - | - |
| **Who calls** | the engine, always on entering the node | the model, when it sees fit |
| **Predictability** | full | depends on the node instruction |
| **Arguments** | `{{var}}` substitution; optionally collected by the model from the dialog (**LLM arguments**) | collected by the model from the argument descriptions |
| **When to use** | a mandatory step: check the slots, create a request | a "depends on the situation" step: the customer may pick a slot or may decline |

![Function node inspector: mock or HTTP, params, response variables](https://mintcdn.com/hubtalk/UuNkjJ26eB-xpPwv/images/tutorial/tut-11-node-function_en.webp?fit=max\&auto=format\&n=UuNkjJ26eB-xpPwv\&q=85\&s=558117f2c27c59955687daa4f7d1e079)

Function. The Mock / HTTP switch, params with \{\{var}}, parsing the response by JSONPath into variables, and a filler reply while the call runs.

> [accordion] Show the whole panel
>
> ![Function node inspector: mock or HTTP, params, response variables](https://mintcdn.com/hubtalk/UuNkjJ26eB-xpPwv/images/tutorial/tut-11-node-function_en.webp?fit=max\&auto=format\&n=UuNkjJ26eB-xpPwv\&q=85\&s=558117f2c27c59955687daa4f7d1e079)

![Conversation inspector with the book\_appointment tool and a model override](https://mintcdn.com/hubtalk/UuNkjJ26eB-xpPwv/images/tutorial/tut-12-conversation-tool_en.webp?fit=max\&auto=format\&n=UuNkjJ26eB-xpPwv\&q=85\&s=8eacd7c1a4dbdbee7088d6bfababf894)

Conversation + tool. The same call, but the model makes the decision: the book\_appointment tool plus its own generation model for this node.

> [accordion] Show the whole panel
>
> ![Conversation inspector with the book\_appointment tool and a model override](https://mintcdn.com/hubtalk/UuNkjJ26eB-xpPwv/images/tutorial/tut-12-conversation-tool_en.webp?fit=max\&auto=format\&n=UuNkjJ26eB-xpPwv\&q=85\&s=8eacd7c1a4dbdbee7088d6bfababf894)

## What you configure in a Function

A tool on a Conversation node is configured with the same form, so everything below applies to both ways.

* **Execution mode** — **Mock (deterministic response)** or **HTTP (real call)**.
* **Name** in the **Function** block — the prefix of the service result variables: a function named `get_free_slots` writes `get_free_slots_status`, `get_free_slots_success`, and so on.
* **Method and URL** — the method is picked from a list: GET, POST, PUT, PATCH, DELETE. The URL, **Query params**, **Headers**, and the body support `{{var}}` substitution and `{{env.NAME}}` secrets. You do not type a secret into the field: you write a reference to it, the value is substituted at execution time and masked in logs.
* **Body (request body)** — for every method except GET; type `json`, `form`, or `raw`. **Content-Type (override)** sets the header by hand; left empty, Content-Type follows the body type.
* **Timeout, sec** — 10 by default, applied to each attempt.
* **Retries** — 0 by default. A retry fires on a network error, a timeout, and a 5xx response; a 4xx response is not retried.
* **Backoff, sec** — 0.5 by default, doubling with each retry: 0.5 → 1 → 2 s. Retries and backoff make the call longer, and the customer waits all that time.
* **Verify TLS certificate (tls\_verify)** — on by default.
* **Success when (success statuses)** — `2xx` by default; you can list codes and ranges separated by commas, for example `200-299, 404`. Any other status is a failure.
* **Response variables** — `slots_count ← $.count`: the variable name on the left, the JSONPath in the response on the right. Only what is listed here becomes a variable. Besides them, the service variables `<name>_status`, `<name>_success` (`true` or `false`), `<name>_error`, and `<name>_result` — the raw response, absent when there was no response — are always available after the call. The status, success, and error of the last call are also in `http_status`, `http_success`, `http_error`. Success / error branching is built on them with an equation.
* **Speak during** — "One moment, let me check the available times…". The agent says it before the request, and `{{var}}` in it are substituted. Advice: in voice this is not decoration — without it the customer hears silence for the whole request. Write the reply in the language of the conversation: for a Russian-speaking agent, for example, «Секунду, смотрю свободное время…».
* **Mock** — a fixed response: **Mock status** and **Mock response** (JSON with `{{var}}`). **Mock scenarios** add named variants: a success with its own status and response, or a `timeout` / `network` failure; **Default active scenario** picks which one answers. You build and test the flow on the mock while the customer's API is not ready: nothing leaves the platform. The function also answers with the mock in the chat test when the run options have **mock** selected for **HTTP functions** — even if the node is in HTTP mode.

The URL must be reachable from the internet: the platform may refuse requests to private and local addresses — then the request is not sent and `<name>_error` is `blocked`. How the platform builds the request and parses the response is described in detail in [the integration contract](https://docs.hubtalk.ai/v4/platform/call-functions/contract.md).

> [!WARNING]
>
> **Pitfall: a failure is a route too**
>
> The network goes down, the CRM answers 500. If a single Always transition leaves the Function, the error travels on as if "all is well" — with empty variables. The right way: after the Function, add a branch on `<name>_success`, for example `{{get_free_slots_success}} == false`, and route the failure to a human or to a polite "we will call you back". A mock scenario with an error helps you check this branch in advance.

> [!TIP]
>
> If your system exposes tools over MCP, there is a third way — the [MCP Tool node](https://docs.hubtalk.ai/v4/platform/agents/nodes#mcp-tool-node). It works like a Function: it calls an MCP server tool on entering the node, arguments take `{{var}}`, response variables use JSONPath, and there is a reply while the call runs.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.