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.
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
Team Communication
Deploy to Slack/Discord for team assistants
Customer SupportTelegram bots for customer interactions
Personal AssistantSingle-user conversational AI
Quick DeploymentOne command to production
# Deploy to Telegram in one command
praisonai bot telegram --token $TELEGRAM_BOT_TOKEN --memory --webWhen to Use Gateway
Web Applications
Custom chat interfaces and dashboards
Multi-Agent SystemsCoordinate multiple specialized agents
Real-time DashboardsLive updates and streaming responses
Custom ProtocolsFull control over communication
# Start gateway for custom applications
praisonai serve gateway --port 8765Architecture Deep Dive
Bot Architecture
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
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
Bot (Telegram)
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:
praisonai bot telegram --token $TOKEN --memory --knowledgeGateway (WebSocket)
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:
praisonai serve gateway --port 8765 --agents agents.yamlMigration Guide
Bot to Gateway
Moving from bot to gateway for more control:
- Extract Agent Configuration
yaml # agents.yaml agents: - name: assistant instructions: Your current bot instructions memory: true tools: - search_web - Start Gateway
bash praisonai serve gateway --port 8765 --agents agents.yaml - 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); };