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

# Bot vs Gateway

> Choose the right deployment model for your AI agents

Two ways to deploy AI agents for real-time communication: **Bot** for messaging platforms, **Gateway** for custom applications.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph TB
    subgraph "Bot Mode"
        U1[👤 User] -->|Message| P[📱 Platform]
        P -->|Webhook| B[🤖 Bot]
        B -->|Response| P
        P -->|Reply| U1
    end
    
    subgraph "Gateway Mode"
        U2[👤 User] -->|WebSocket| G[🗼 Gateway]
        G -->|Route| A1[🤖 Agent 1]
        G -->|Route| A2[🤖 Agent 2]
        A1 -->|Response| G
        G -->|Deliver| U2
    end
    
    classDef user fill:#8B0000,color:#fff
    classDef platform fill:#189AB4,color:#fff
    classDef bot fill:#8B0000,color:#fff
    classDef gateway fill:#F59E0B,color:#fff
    classDef agent fill:#8B0000,color:#fff
    
    class U1,U2 user
    class P platform
    class B bot
    class G gateway
    class A1,A2 agent
```

***

## Quick Comparison

| Feature | Bot | Gateway |
| - | - | - |
| **Use Case** | Messaging platforms | Custom applications |
| **Platforms** | Telegram, Discord, Slack | Any WebSocket client |
| **Users** | Single-user conversations | Multi-user, multi-agent |
| **Protocol** | Platform-specific | WebSocket |
| **CLI** | `praisonai bot <platform>` | `praisonai serve gateway` |

***

## When to Use Bot

> [card] Team Communication
>
> Deploy to Slack/Discord for team assistants

> [card] Customer Support
>
> Telegram bots for customer interactions

> [card] Personal Assistant
>
> Single-user conversational AI

> [card] Quick Deployment
>
> One command to production

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Deploy to Telegram in one command
praisonai bot telegram --token $TELEGRAM_BOT_TOKEN --memory --web
```

***

## When to Use Gateway

> [card] Web Applications
>
> Custom chat interfaces and dashboards

> [card] Multi-Agent Systems
>
> Coordinate multiple specialized agents

> [card] Real-time Dashboards
>
> Live updates and streaming responses

> [card] Custom Protocols
>
> Full control over communication

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Start gateway for custom applications
praisonai serve gateway --port 8765
```

***

## Architecture Deep Dive

> [tab] Bot Architecture
>
> ```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
> sequenceDiagram
>     participant User
>     participant Platform as Telegram/Discord/Slack
>     participant Bot as PraisonAI Bot
>     participant Agent
>
>     User->>Platform: Send message
>     Platform->>Bot: Webhook/Polling
>     Bot->>Agent: Process with tools
>     Agent-->>Bot: Response
>     Bot->>Platform: Send reply
>     Platform-->>User: Display message
> ```
>
> **Key Points:**
>
> * Platform handles user authentication
> * Bot receives messages via webhook or polling
> * Multi-agent routing per bot (dm → agent A, group → agent B)
> * Platform-specific features (reactions, threads, etc.)

> [tab] Gateway Architecture
>
> ```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
> sequenceDiagram
>     participant Client as Web Client
>     participant Gateway
>     participant Session
>     participant Agent1 as Agent 1
>     participant Agent2 as Agent 2
>
>     Client->>Gateway: Connect (WebSocket)
>     Gateway->>Session: Create session
>     Gateway-->>Client: Session ID
>     Client->>Gateway: Join agent-1
>     Gateway->>Agent1: Route message
>     Agent1->>Agent2: Handoff (if needed)
>     Agent2-->>Gateway: Response
>     Gateway-->>Client: Deliver response
> ```
>
> **Key Points:**
>
> * Direct WebSocket connection
> * Multiple agents per gateway
> * Session-based state management
> * Agent-to-agent communication

***

## Feature Comparison

### Capabilities Support

| Capability | Bot | Gateway |
| - | - | - |
| Memory | ✅ `--memory` | ✅ Session state |
| Knowledge/RAG | ✅ `--knowledge` | ✅ Per-agent |
| Tools | ✅ `--tools` | ✅ Per-agent |
| Web Search | ✅ `--web` | ✅ Per-agent |
| Browser | ✅ `--browser` | ✅ Per-agent |
| Thinking Mode | ✅ `--thinking` | ✅ Per-agent |
| Multi-Agent | ✅ Context-based routing | ✅ Multiple agents with routing |
| Multi-Platform | ✅ All 4 platforms concurrently | ✅ WebSocket + bots |
| Custom UI | ❌ Platform UI | ✅ Full control |

### Deployment

| Aspect | Bot | Gateway |
| - | - | - |
| Setup | Platform token required | No external deps |
| Scaling | Multiple bots per platform via `platform:` field | Multiple clients per gateway |
| Auth | Platform handles | You implement |
| SSL | Platform handles | You configure |

***

## Code Examples

> [tab] Bot (Telegram)
>
> ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
> from praisonai.bots import TelegramBot
> from praisonaiagents import Agent
>
> # Create agent with capabilities
> agent = Agent(
>     name="assistant",
>     instructions="You are a helpful assistant.",
>     memory=True,
>     knowledge=["./docs/"]
> )
>
> # Deploy to Telegram
> bot = TelegramBot(
>     token="YOUR_BOT_TOKEN",
>     agent=agent
> )
>
> # Start bot
> await bot.start()
> ```
>
> **CLI equivalent:**
>
> ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
> praisonai bot telegram --token $TOKEN --memory --knowledge
> ```

> [tab] Gateway (WebSocket)
>
> ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
> from praisonai.gateway import WebSocketGateway
> from praisonaiagents import Agent, GatewayConfig
>
> # Create gateway
> config = GatewayConfig(host="0.0.0.0", port=8765)
> gateway = WebSocketGateway(config=config)
>
> # Register multiple agents
> researcher = Agent(name="researcher", instructions="Research topics")
> writer = Agent(name="writer", instructions="Write content")
>
> gateway.register_agent(researcher)
> gateway.register_agent(writer)
>
> # Start gateway
> await gateway.start()
> ```
>
> **CLI equivalent:**
>
> ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
> praisonai serve gateway --port 8765 --agents agents.yaml
> ```

***

## Migration Guide

### Bot to Gateway

Moving from bot to gateway for more control:

**1. Extract Agent Configuration**

```yaml theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# agents.yaml
agents:
  - name: assistant
    instructions: Your current bot instructions
    memory: true
    tools:
      - search_web
```

**2. Start Gateway**

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai serve gateway --port 8765 --agents agents.yaml
```

**3. Connect Your Client**

```javascript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
const ws = new WebSocket('ws://localhost:8765/ws');

ws.onopen = () => {
  ws.send(JSON.stringify({
    type: 'join',
    agent_id: 'assistant'
  }));
};

ws.onmessage = (event) => {
  const data = JSON.parse(event.data);
  console.log('Response:', data.content);
};
```

***

## Decision Tree

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph TD
    A[Need real-time AI?] -->|Yes| B{Platform?}
    B -->|Telegram/Discord/Slack| C[Use Bot]
    B -->|Custom App| D{Multi-agent?}
    D -->|Yes| E[Use Gateway]
    D -->|No| F{Need custom UI?}
    F -->|Yes| E
    F -->|No| G[Consider Bot or Gateway]
    
    classDef decision fill:#F59E0B,color:#fff
    classDef result fill:#8B0000,color:#fff
    
    class A,B,D,F decision
    class C,E,G result
```

***

## Related

> [card] [Bot CLI](https://praison.ai/docs/cli/bot.md)
>
> Full bot CLI reference

> [card] [Gateway Feature](https://praison.ai/docs/features/gateway.md)
>
> Gateway configuration guide

> [card] [Multi-Agent](https://praison.ai/docs/features/multi-agent)
>
> Multi-agent coordination

> [card] [Serve CLI](https://praison.ai/docs/cli/serve.md)
>
> All serve commands


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