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

# Function Aggregator

> Combine flow actions and agent functions into sequentially executed scenarios.

# Function Aggregator

`FUNCTION_AGG` is a native aggregator for actions and `function_calls`. The AI selects a scenario, and the system merges the `default` configuration with the selected scenario.

Aggregated functions run sequentially. The resulting flow actions are returned for later execution by the pipeline.

## Tool payload

`scenario` is required. It must be part of the tool `enum` and exist in `scenarios`:

```json theme={null}
{
  "scenario": "qualified"
}
```

## Configuration

```json theme={null}
{
  "function_type": "FUNCTION_AGG",
  "default": {
    "killQueues": true,
    "blockAI": false,
    "transferTeam": null,
    "resolveConversation": false,
    "disableFollowup": true,
    "add_label": [],
    "remove_label": [],
    "function_calls": ["notify_crm"]
  },
  "scenarios": {
    "qualified": {
      "resolveConversation": true,
      "function_calls": [
        {
          "name": "notify_crm",
          "arguments": {
            "status": "qualified"
          }
        }
      ]
    }
  }
}
```

| Field                 | Type                   | Effect                                           |
| --------------------- | ---------------------- | ------------------------------------------------ |
| `killQueues`          | `boolean`              | Removes pending scheduled jobs                   |
| `blockAI`             | `boolean`              | Blocks the AI and creates a private notification |
| `transferTeam`        | `number \| null`       | Transfers the conversation to a CriaChat team    |
| `resolveConversation` | `boolean`              | Resolves the conversation                        |
| `disableFollowup`     | `boolean`              | Saves `allow_followup = false`                   |
| `add_label`           | `string[]`             | Adds labels                                      |
| `remove_label`        | `string[]`             | Removes labels                                   |
| `function_calls`      | `string[] \| object[]` | Agent functions run sequentially                 |

## Response

```json theme={null}
{
  "success": true,
  "scenario": "qualified",
  "actions_deferred": {
    "killQueues": true,
    "blockAI": true,
    "transferTeam": 1,
    "resolveConversation": false,
    "disableFollowup": true
  }
}
```

`actions_deferred` receives the complete resolved object and may also include `add_label`, `remove_label`, `leadAction`, and `function_calls`.
