Skip to main content
Messaging Bots enable your AI agents to interact with users across Telegram, Discord, Slack, WhatsApp, and Linear.
The user messages the bot on their preferred channel; the same agent logic handles the conversation.
The same agent can serve one unified conversation per human across all platforms with Cross-Platform Sessions — message from Telegram in the morning, Discord at noon, and keep the same conversation history.

Quick Start

Bot(...).run() auto-reconnects on a dropped connection by default — see Auto-reconnect on long-running-bots.
Start a bot with a single command - no Python code required:
1

Set Environment Variables

2

Start the Bot

A default agent is created automatically with basic assistant capabilities.
3

(Optional) Custom Agent

agents.yaml:

Supported Platforms

Bot Runtimes (Bidirectional — Send + Receive)

Outbound Tools (Send-Only — Bot Runtime Coming Soon)

Outbound tools are from praisonai-tools for sending messages from agents. For receiving messages via bot runtime, use the CLI or Python SDK shown above.Install: pip install praisonai-tools

Durable Outbound Delivery — All Channels

As of 2026-06-30, durable outbound delivery with bounded exponential backoff now covers all six bot adapters — Slack, Discord, WhatsApp, Email, Linear, and AgentMail — not only Telegram. Before this change, only Telegram retried agent replies on transient 5xx / rate-limit / network errors; the other adapters silently dropped failed sends. Now every adapter retries with the same guarantee, and a configured DLQ parks the message instead of dropping it on permanent failure.
Configure outbound resilience via config.outbound_resilience — the same config block applies to every adapter:
Without a dlq_path, the adapter retries but never silently drops — it raises after exhausting attempts. With a dlq_path, a permanent failure parks the message to disk for manual inspection or replay.

Durable Delivery

Full reference: retry config, DLQ, drain-on-restart, and per-adapter _outbound_platform labels
Two different flows can prepend a recovered-reply marker after a gateway restart:Both are honest labels, not bugs.

Inbound Media → Vision

Both WhatsApp and Telegram bots forward photos and documents directly to your agent’s vision capability. On Telegram, a media album is coalesced into a single turn — see Media Albums.
Send the bot a photo with or without a caption — the agent sees the image directly.
Backward compatible: if your agent doesn’t accept attachments, the bot skips the file and forwards only the caption text. Text-only agents need zero changes.

WhatsApp Inbound Media

WhatsApp-specific details: Graph API download, security pipeline, and max_inbound_media_bytes config

Bot Inbound Media

Full reference: security pipeline, SSRF guard, size limits, and common patterns

Outbound Media Delivery

Send agent-generated images, charts, and files via native platform uploads

How It Works


Wiring Button Clicks

Buttons and select menus rendered by your bot can be wired to your own async handlers — slash-command buttons work out of the box, and you can register custom namespaces for things like approvals, menus, or multi-step flows. See Interactive Bot Actions.

AIUI Dashboard Integration

When bots are connected through PraisonAI UI (praisonai chat), channel messages appear in the Chat dashboard with full visibility into agent processing steps — tool calls, reasoning, and intermediate responses stream in real-time.

What You See in the Dashboard

The streaming bridge hooks into the same StreamEventEmitter used by the web chat, so channel messages get identical step visibility as messages typed directly in the dashboard.

Smart Defaults

Bots ship with sensible defaults so you can start chatting immediately — no tool wiring required. Both praisonai bot start and praisonai gateway start apply the same defaults:

Opting out

Destructive tools (execute_command, delete_file, write_file, shell_command) are never auto-injected, even if you add them to default_tools. Wire them explicitly on the agent and add a chat-level approval flow.
Upgrading from an older release? auto_approve_tools used to default to False. If your bot relied on manual approval, set auto_approve_tools: false explicitly.
Pending approvals can survive a bot restart when you configure an ApprovalStore — late Allow/Deny taps still resolve after a deploy.Telegram-native durable approvals. On Telegram, setting Agent(approval="presentation") is enough — the bot auto-wires the durable backend to the chat on start and rehydrates pending approvals across restarts. See Telegram Durable Approval.

Platform Awareness

Every bot automatically tells the agent which platform it’s on, what kind of chat it’s in, and which channels it can reach.
This is enabled by default via inject_session_context=True on BotSessionManager. The agent receives a ## Session Context block in its system prompt each turn — for example: “You are replying on telegram (group ‘Project Alpha’) in thread 123. Reachable delivery targets: slack:home, team (slack:C0123).”To suppress the visible block (context still flows to tools), set inject_session_context=False. See Platform-Aware Agents for the full configuration reference.

Socket Mode vs Webhook

PraisonAI bots support two connection modes:
Socket Mode works by opening an outbound WebSocket connection to Slack/Discord. No public URL or port forwarding is needed - your bot initiates the connection from behind NAT/firewall.

Configuration Options

Reply behavior:
  • Default: Inline replies in the channel
  • Auto-thread: Responses > 500 chars are automatically threaded
  • Force thread: Set reply_in_thread=True to always use threads
Group policy:
  • mention_only — Bot only responds when @mentioned (default, safest)
  • respond_all — Bot responds to every message in the group
  • command_only — Bot only responds to /commands
  • observe — Bot stays silent like mention_only, but keeps unmentioned group messages as passive context so it can answer with full awareness when next mentioned (Telegram only). See observe: passive group context.
When running via the gateway, set group_policy per channel in gateway.yaml. See Bot Gateway → Channel Security.
Sender name sanitisation is on by default. Display names in group / multi-party chats are neutralised (newlines collapsed, control chars stripped, length-bounded to 240) before they are interpolated into the [{sender}] attribution prefix, so a hostile name can’t masquerade as a fake system directive. See Sender Attribution Sanitisation for details.
For the full owner-approval workflow (inline buttons on Telegram / Discord / Slack, HMAC signing, CLI fallback), see Bot Unknown-User Pairing.

Access-check methods

BotConfig exposes two allowlist checks with distinct purposes:
Custom adapters should guard the pairing flow with is_explicitly_allowed() so a policy-allowed unknown user still gets pairing/deny semantics — PR #2856.

CLI Capabilities

Enable powerful agent features directly from the command line:

Memory

Bot remembers previous conversations

Knowledge/RAG

Answer from your documents

Skills

Load named skill modules

Extended Thinking

Enable reflection mode (off/minimal/low/medium/high)

Platform Setup

  1. Message @BotFather on Telegram
  2. Send /newbot and follow prompts
  3. Copy the bot token

Bot Commands

Built-in commands available on all platforms:
Telegram also ships /automations and /blueprint for consent-first scheduled automations — see Automation Suggestions. Other adapters don’t register these yet.
You can register custom commands programmatically:
See Bot Chat Commands for full details on custom command registration and platform-specific behavior.

Common Patterns


CLI Commands

The Slack bot uses Slack Bolt, Slack’s official Python framework. When running, you’ll see “⚡️ Bolt app is running!” - this confirms the bot is connected and listening.

WhatsApp Message Filtering (Web Mode)

By default, WhatsApp Web mode responds only to self-chat messages — when you message your own number. This prevents the bot from replying to every conversation on your account, including messages you send in other people’s chats.
Self-chat means messaging your own phone number — not just any message you send. Messages you send in other people’s chats or groups are filtered out by default.

CLI Flags

Python SDK

YAML Config

Filtering Behavior Matrix

Phone numbers are normalized automatically — +1-234-567-890, 1234567890, and (123) 456-7890 all match the same number. Group IDs use WhatsApp’s JID format (e.g., 120363123456@g.us).Stale message guard: Messages older than when the bot connected are always dropped, even with --respond-to-all. This prevents replaying old conversations on reconnect.

Docker Deployment

Deploy bots using Docker for production environments:
docker-compose.yml:
For production, build a dedicated Docker image instead of installing dependencies at runtime. See the docker/bots folder for ready-to-use Dockerfiles.

Production (Webhook Mode)

For production deployments with a public URL, use webhook mode instead of Socket Mode:
Configure in Slack API Console:
  1. Event Subscriptions → Enable Events
  2. Set Request URL: https://your-domain.com/slack/events
  3. Subscribe to bot events: app_mention, message.im
Webhook mode requires:
  • Public HTTPS URL with valid SSL certificate
  • Port 443 (or 80/88/8443 for Telegram)
  • Firewall rules allowing inbound connections

Multi-Channel Gateway

Run all bots simultaneously with a single gateway config: gateway.yaml:
Channel key vs platform — in gateway.yaml, the YAML key under channels: (e.g. telegram, telegram_cfo) is just an identifier you choose. When the key is not a platform name, set platform: telegram (or whichever) inside the block so the gateway can pick the right protocol. This enables running multiple bots on the same platform. Note: bot.yaml requires channel keys to be platform names.
Behind the scenes the gateway calls Agent.clone_for_channel() on the configured agent for each channel, so per-channel tools or routing rules never leak between bots. See Agent Cloning.
The gateway now produces identical results to Bot() — agents get the same safe tools and auto-approval in both entry points.
The gateway uses routing rules to send messages to different agents based on context (DM vs group vs channel). Each channel can have its own routing configuration.

Multiple bots on the same platform

For role-specific bots on the same platform (e.g., multiple Telegram bots), use this pattern:
See the Multi-Channel Bots guide for complete setup instructions including the onboard wizard flow and validation with praisonai doctor.

Zero-Code Mode (YAML Config)

Run a bot with a single YAML file — no Python code needed: bot.yaml:
Tip: You can omit tools: entirely — the bot auto-injects safe defaults (search_web, schedule, memory, learning). Keep tools: [] only if you want the bot to run with zero tools.
The .env file in the current directory is auto-loaded, so you can store tokens there and reference them with ${VAR_NAME} syntax.

Token Types — When to Use What

Different platforms use different types of tokens. Here’s when to use each:

Telegram

Discord

Slack

Common mistake: Using Client ID/Secret instead of Bot Token + App Token. For most bots, you only need:
  • SLACK_BOT_TOKEN (xoxb-…) — for API operations
  • SLACK_APP_TOKEN (xapp-…) — for Socket Mode connection
Client ID and Client Secret are only needed if you’re distributing your app to multiple Slack workspaces via OAuth.

WhatsApp


Best Practices

Never commit bot tokens to version control. Use environment variables or secure secret management.
Set allowed_users and allowed_channels to prevent unauthorized access to your bot.
Set mention_required=True to prevent the bot from responding to every message in group chats.
Outbound sends now honour the platform’s Retry-After / retry_after automatically — both on live retries (deliver_with_retry) and on durable drains (OutboundQueue). To make the limiter widen the lane for the rest of your bot’s concurrent sends, pass a shared RateLimiter into deliver_with_retry(rate_limiter=...). See Bot Rate Limiting and Durable Delivery.
The default tool list is intentionally safe (search_web, schedule_*, memory/learning). Tools like execute_command require explicit opt-in and should be paired with an approval backend. See Approval Protocol.
Only set auto_approve_tools: false if you’ve wired a chat-level approval flow (e.g. SlackApproval). Otherwise tool calls will hang silently waiting for a CLI prompt the user cannot see.
If you set channels.<platform>.allow_shell: true with auto_approve_shell: false, the gateway now wires SlackApproval / TelegramApproval / DiscordApproval automatically — no Python glue required. And auto_approve_shell: true is automatically downgraded to the same wiring on externally-bound gateways or channels with a group_policy, unless auto_approve_shell_acknowledge_exposed: true opts in. See Bot Shell Execution.

Multi-Agent Configuration

You can also define multiple agents in an agents.yaml file for complex workflows: agents.yaml:

Inbound Message Debounce

When users send multiple rapid messages (e.g. “hey” → “can you” → “search for AI news”), debounce coalesces them into a single agent call — saving tokens and preventing duplicate responses.
Set debounce_ms: 0 (default) to disable debouncing for real-time response bots. Recommended: 1000–2000ms for conversational bots.
The per-user debounce lock cache is bounded (default: 10,000 entries, 1 hour TTL). Long-running bots with millions of distinct users won’t leak memory — idle entries are evicted automatically.

Smart Message Chunking

Long agent responses are split at paragraph boundaries while preserving code fences — no more broken code blocks mid-message.
1

Paragraph boundaries

Split at blank lines (\n\n) first — keeps ideas together.
2

Sentence boundaries

If a paragraph is still too long, split at sentence endings (. ).
3

Hard split

Last resort: character-level split for very long single lines.
Code blocks wrapped in triple backticks are never split, even if they exceed max_message_length. This ensures your users always see complete, copyable code.
Smart chunking is enabled automatically for all bot adapters. No configuration needed. Override max_message_length in BotConfig to change the split threshold (default: 4096).

Session History

Bot agents automatically remember the last 20 messages per conversation — no extra dependencies required.
Setting memory=True (full memory with ChromaDB) requires pip install praisonaiagents[memory]. The default history=True injection uses zero extra dependencies.

Ack Reactions

Acknowledge inbound messages with an emoji reaction (e.g. ⏳) so users know the bot is processing, then swap to a done emoji (e.g. ✅) when the response is sent.
Onboard-generated configs enable / by default. Set ack_emoji: "" to opt out. Currently wired for Telegram (which supports native message reactions).

Long-Running Agent Feedback

RAG-enabled agents commonly take 20–30 seconds to answer (vector search + tool calls + LLM). PraisonAI Telegram bots give users continuous feedback throughout, with no extra code on your side.

What the user sees

Why this matters


Session Reset Policy

Per-channel YAML policies automatically clear a user’s conversation history after idle time or at a scheduled hour — configured under session.reset on each channel.

Bot Session Reset

Idle, daily, and combined reset modes with full configuration reference

Session Reaper

Automatically prune stale sessions to free memory on long-running bots. Sessions idle longer than session_ttl seconds are reaped.
Set session_ttl: 0 (default) to disable automatic reaping. You can also call bot._session.reap_stale(max_age_seconds) manually.

YAML Configuration

Deploy bots entirely from YAML — including agent memory, tools, roles, and multi-platform config.
Use ${ENV_VAR} in YAML values — resolved at load time.

Tool Approval via Messaging

When your bot agent uses dangerous tools (e.g. execute_command), you can route approval requests to Slack:
Add store=ApprovalStore(...) to make Slack approvals survive a bot restart. See Durable Approvals.
See Approval Protocol for full configuration options.

Bot Rate Limiting

Prevent 429 errors with platform-aware rate limiting

Send Policy

Authorise where bots may send — allow/deny guard for send_message

Ask Conversation

Let agents ask another chat a question mid-turn and act on the reply

Approval Protocol

Tool execution approval system

Gateway

Multi-agent coordination

Webhooks

Event-driven integrations

Bot Platform Capabilities

How platform capabilities drive this feature

Channel Descriptor

Let a channel plugin declare its config, prompt hint, and setup wizard

Bot Session Compaction

Summarise old turns instead of dropping them

Outbound Media Delivery

Deliver agent-generated images and files to users on Telegram, Slack, and Discord