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

# Call AI Agent Node

> Invoke other CogniAgent applications as reusable building blocks

The Call Agent node invokes another CogniAgent application within your workflow. This enables modular design where complex logic can be encapsulated in one application and reused across many others.

<Frame caption="Call AI Agent configuration — pick the target application and map values into its input arguments.">
  <img src="https://mintcdn.com/glorium/eqWkhSfBUec9afZU/images/nodes/node-call-ai-agent-form.png?fit=max&auto=format&n=eqWkhSfBUec9afZU&q=85&s=ca5378d0841d861e172fc337ec387d8e" alt="Call AI Agent node configuration form" width="1440" height="1200" data-path="images/nodes/node-call-ai-agent-form.png" />
</Frame>

## When to Use

* **Reusable logic** - Encapsulate common workflows (email parsing, data validation) and call them from multiple places
* **Complex sub-processes** - Break large workflows into manageable pieces
* **Team collaboration** - Different team members can own different agents
* **Versioning** - Update a shared agent without modifying every workflow that uses it
* **Separation of concerns** - Keep workflows focused on one responsibility

<Tip>
  Think of Call Agent like calling a function in programming. The called agent is the function, and your inputs are the parameters.
</Tip>

## Example: Lead Qualification Pipeline

A main workflow that uses specialized agents for each step:

<Steps>
  <Step title="Receive the lead">
    Use a Webhook node to receive new lead data from your website form.
  </Step>

  <Step title="Enrich the lead">
    Call Agent: **Lead Enrichment Agent**

    ```json theme={null}
    {
      "email": "{{webhook_1.body.email}}",
      "company": "{{webhook_1.body.company}}"
    }
    ```

    This agent looks up company info, social profiles, and tech stack.
  </Step>

  <Step title="Score the lead">
    Call Agent: **Lead Scoring Agent**

    ```json theme={null}
    {
      "enrichedData": "{{call_agent_1.result}}",
      "source": "{{webhook_1.body.source}}"
    }
    ```

    This agent applies your scoring model and returns a score.
  </Step>

  <Step title="Route based on score">
    Use a Condition node to route high-score leads to sales, others to nurture campaigns.
  </Step>
</Steps>

**Workflow structure:**

```
├── Webhook (receive lead)
├── Call Agent (Lead Enrichment Agent)
├── Call Agent (Lead Scoring Agent)
├── Condition (score > 80?)
│   ├── Met: External API (create Salesforce opportunity)
│   └── Unmet: External API (add to nurture campaign)
```

## Example: Document Processing Hub

A central workflow that routes documents to specialized processors:

```
├── Webhook (receive document)
├── Read File (extract content)
├── Ask AI (classify document type)
├── Multi-Condition (based on document type)
│   ├── invoice: Call Agent (Invoice Processor)
│   ├── contract: Call Agent (Contract Analyzer)
│   ├── resume: Call Agent (Resume Parser)
│   └── default: Call Agent (Generic Document Handler)
└── External API (store results)
```

Each specialized agent handles its document type with custom logic.

## Example: Approval Workflow

Use agents to encapsulate approval processes:

**Main workflow:**

```
├── Event from App (new purchase request in Slack)
├── Call Agent (Expense Approval Agent)
│   Input: {amount, requestor, description, receipts}
├── Condition (approved?)
│   ├── Met: External API (process payment)
│   └── Unmet: External API (notify requestor of rejection)
```

**Expense Approval Agent:**

```
├── Start
├── Condition (amount > 500?)
│   ├── Met: Human (manager approval required)
│   └── Unmet: Ask AI (auto-approve with policy check)
└── Return result
```

## Passing Data

### Input Data

Pass data to the agent as a JSON object:

```json theme={null}
{
  "customerId": "{{webhook_1.body.customerId}}",
  "orderDetails": {
    "items": "{{webhook_1.body.items}}",
    "total": "{{webhook_1.body.total}}"
  },
  "priority": "high"
}
```

The called agent receives this as its starting input data.

### Receiving Results

The called agent's output becomes available as `{{call_agent_1.result}}`:

```
Customer name: {{call_agent_1.result.customerName}}
Credit score: {{call_agent_1.result.creditScore}}
Approved: {{call_agent_1.result.approved}}
```

## Design Patterns

### Microservices Pattern

Break your automation into small, focused agents:

| Agent              | Responsibility                     |
| ------------------ | ---------------------------------- |
| Email Parser       | Extract data from emails           |
| Sentiment Analyzer | Determine sentiment of text        |
| CRM Updater        | Handle all CRM operations          |
| Notifier           | Send notifications across channels |

Main workflows compose these agents as needed.

### Facade Pattern

Create a simplified agent that orchestrates complex operations:

**Customer Onboarding Agent** (called by main workflow):

```
├── Create CRM record
├── Set up billing account
├── Send welcome email
├── Add to onboarding sequence
├── Notify account manager
└── Return summary
```

Callers don't need to know these details.

### Chain of Responsibility

Pass data through a series of processing agents:

```
├── Call Agent (Validator) → validates input
├── Call Agent (Enricher) → adds data
├── Call Agent (Scorer) → calculates score
├── Call Agent (Router) → determines destination
```

## Async Execution

Set `waitForCompletion: false` for fire-and-forget scenarios:

```
├── Webhook (receive batch request)
├── Loop (over items)
│   └── Call Agent (Process Item, async)
└── HTTP Response ("Processing started")
```

<Note>
  Async calls return immediately with an `executionId`. You won't get the result in the current workflow - use webhooks or variables for callbacks.
</Note>

## Error Handling

When a called agent fails, the Call Agent node captures the error:

```
├── Call Agent (risky operation)
├── Condition (status == "completed")
│   ├── Met: Continue normal flow
│   └── Unmet: External API (alert team)
```

Check `{{call_agent_1.status}}` to handle failures gracefully.

## Tips

<Tip>
  Name agents descriptively - "Invoice Processor v2" is better than "Agent 1". This makes the Call Agent node's purpose clear in the workflow.
</Tip>

<Tip>
  Version your agents by creating copies before major changes. This prevents breaking dependent workflows.
</Tip>

<Warning>
  Avoid circular dependencies where Agent A calls Agent B which calls Agent A. This will cause infinite loops and eventual timeout.
</Warning>

## Settings

<ParamField path="name" type="string" default="Call Agent">
  Display name shown on the canvas.
</ParamField>

<ParamField path="key" type="string" default="call_agent_1">
  Unique identifier for referencing outputs.
</ParamField>

<ParamField path="agentId" type="string" required>
  The ID of the CogniAgent application to call. Select from a dropdown of available agents in your workspace.
</ParamField>

<ParamField path="inputData" type="object">
  Data to pass to the called agent. This becomes the agent's starting input.
</ParamField>

<ParamField path="waitForCompletion" type="boolean" default="true">
  Whether to wait for the agent to complete before continuing:

  * **true** - Wait and get the results
  * **false** - Fire and forget (async execution)
</ParamField>

<ParamField path="timeout" type="number" default="300000">
  Maximum time to wait for completion (in milliseconds). Default is 5 minutes.
</ParamField>

## Outputs

<ParamField path="result" type="any">
  The output data returned by the called agent (from its final node or explicit return).
</ParamField>

<ParamField path="executionId" type="string">
  Unique identifier for this execution of the called agent.
</ParamField>

<ParamField path="status" type="string">
  Execution status: `completed`, `failed`, or `timeout`.
</ParamField>

<ParamField path="duration" type="number">
  How long the agent took to execute (in milliseconds).
</ParamField>

## Related Nodes

<CardGroup cols={2}>
  <Card title="Ask AI" icon="message-bot" href="/nodes/actions/ask-ai">
    For simple AI tasks, an Ask AI node may be sufficient without a full agent.
  </Card>

  <Card title="Execute Code" icon="code" href="/nodes/actions/execute-code">
    For data processing, code might be simpler than an agent.
  </Card>
</CardGroup>
