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.

Diagram

Gateway Mode

WebSocket

Route

Route

Response

Deliver

👤 User

🗼 Gateway

🤖 Agent 1

🤖 Agent 2

Bot Mode

Message

Webhook

Response

Reply

👤 User

📱 Platform

🤖 Bot


Quick Comparison

FeatureBotGateway
Use CaseMessaging platformsCustom applications
PlatformsTelegram, Discord, SlackAny WebSocket client
UsersSingle-user conversationsMulti-user, multi-agent
ProtocolPlatform-specificWebSocket
CLIpraisonai bot <platform>praisonai serve gateway

When to Use Bot

bash
# Deploy to Telegram in one command
praisonai bot telegram --token $TELEGRAM_BOT_TOKEN --memory --web

When to Use Gateway

bash
# Start gateway for custom applications
praisonai serve gateway --port 8765

Architecture Deep Dive

Bot Architecture

Diagram
AgentPraisonAI BotTelegram/Discord/SlackUserAgentPraisonAI BotTelegram/Discord/SlackUserSend messageWebhook/PollingProcess with toolsResponseSend replyDisplay 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.)

Gateway Architecture

Diagram
Agent 2Agent 1SessionGatewayWeb ClientAgent 2Agent 1SessionGatewayWeb ClientConnect (WebSocket)Create sessionSession IDJoin agent-1Route messageHandoff (if needed)ResponseDeliver response

Key Points:

  • Direct WebSocket connection
  • Multiple agents per gateway
  • Session-based state management
  • Agent-to-agent communication

Feature Comparison

Capabilities Support

CapabilityBotGateway
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

AspectBotGateway
SetupPlatform token requiredNo external deps
ScalingMultiple bots per platform via platform: fieldMultiple clients per gateway
AuthPlatform handlesYou implement
SSLPlatform handlesYou configure

Code Examples

Bot (Telegram)

python
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
praisonai bot telegram --token $TOKEN --memory --knowledge

Gateway (WebSocket)

python
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
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
    # agents.yaml
    agents:
      - name: assistant
        instructions: Your current bot instructions
        memory: true
        tools:
          - search_web
  2. Start Gateway
    bash
    praisonai serve gateway --port 8765 --agents agents.yaml
  3. Connect Your Client
    javascript
    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

Diagram

Yes

Telegram/Discord/Slack

Custom App

Yes

No

Yes

No

Need real-time AI?

Platform?

Use Bot

Multi-agent?

Use Gateway

Need custom UI?

Consider Bot or Gateway


Related