Skip to content

Agent Decision

This module evaluates the current state of a conversation and determines the action to follow. It supports three decision modes:

  1. Rules: Evaluates a set of configured rules against the input data. Each rule defines a field, operator, value, and resulting action. Supported operators include: equals, not_equals, greater_than, less_than, contains, not_contains, is_empty, is_not_empty, in, not_in.
  2. AI: Sends the conversation context to an LLM that analyzes and decides the action. Uses low temperature (0.3) for consistent decisions. Can use the same brain configured in the session’s agent or its own.
  3. Hybrid: First evaluates the rules; if none apply, falls back to AI.

The possible actions are:

  • continue: The conversation continues normally (status: active).
  • pause: Pause the conversation (status: dormant).
  • close: Close the conversation (status: closed).
  • escalate: Escalate to a human (status: active, marked for escalation).
  • archive: Archive the conversation (status: archived).

The module has 5 output ports, one for each action, allowing the flow to be directed differently based on the decision made. It optionally updates the session status in the database.

ParameterTypeRequiredDescription
decision_modeselectYesHow decisions are made. Options: rules, ai, hybrid. Default: rules.
rulesagentDecisionRulesNoConfigures the rules for making automatic decisions.
ai_prompttextareaNoInstructions for the AI to determine the action to take. Visible in ai and hybrid modes.
use_session_brainbooleanNoUse the same AI configured in the agent. Default: true. Visible in ai and hybrid modes.
brain_providerselectNoAI provider. Options: openai, anthropic, google, deepseek, qwen, llama. Visible if use_session_brain is false.
brain_modelaiModelSelectorNoAI model to use. Visible based on brain_provider. Default: gpt-4o.
credentials_keycredentialsNoProvider credentials. Visible if use_session_brain is false.
default_actionselectYesAction when no rule applies. Options: continue, pause, close, escalate, archive. Default: continue.
update_session_statusbooleanNoAutomatically update the session status based on the decision. Default: true.

Optional. If use_session_brain is true, the session agent’s credentials are reused. Otherwise, credentials_key must be configured with credentials of type: openai, anthropic, google_ai, deepseek, qwen, llama.

{
"success": true,
"action": "continue",
"reason": "Regla aplicada: mensajes > 5",
"confidence": 1.0,
"session_id": "uuid-sesion",
"previous_status": "active",
"new_status": "active",
"decision_mode": "rules",
"decided_at": "2026-03-23T10:00:00.000Z",
"_outputPort": "continue"
}
{
"decision_mode": "rules",
"rules": [
{
"field": "follow_up_number",
"operator": ">=",
"value": "3",
"action": "close",
"name": "Cerrar tras 3 follow-ups sin respuesta"
}
],
"default_action": "continue",
"update_session_status": true
}
  • session_id: Agent session ID.
  • follow_up_number: Current follow-up number.
  • previous_follow_ups: Number of follow-ups sent.
  • minutes_since_last_message: Minutes since the last message.
  • messages_count: Total messages in the session.
  • session_status: Current session status.
  • memory: Session memory.
  • entities: Extracted entities.

In AI or hybrid mode, the configured provider’s API (OpenAI, Anthropic, Google, etc.) is called for the LLM to make the decision.

  • The _outputPort field in the output determines which of the 5 ports the flow exits through (continue, pause, close, escalate, archive).
  • In hybrid mode, rules take priority over AI.
  • AI decision uses temperature 0.3 for greater consistency.
  • If the AI cannot parse a valid response, the default action is used.
  • Input data is passed completely to the next node along with the decision result.