Skip to main content
Messaging Bots enable your AI agents to interact with users across 11+ messaging platforms.

Quick Start

Start a bot with a single command - no Python code required:
1

Set Environment Variables

# Telegram
export TELEGRAM_BOT_TOKEN="123456:ABC-DEF..."

# Discord
export DISCORD_BOT_TOKEN="MTIz..."

# Slack (requires both tokens)
export SLACK_BOT_TOKEN="xoxb-..."
export SLACK_APP_TOKEN="xapp-..."
2

Start the Bot

# Telegram
praisonai bot telegram --token $TELEGRAM_BOT_TOKEN

# Discord
praisonai bot discord --token $DISCORD_BOT_TOKEN

# Slack
praisonai bot slack --token $SLACK_BOT_TOKEN --app-token $SLACK_APP_TOKEN
A default agent is created automatically with basic assistant capabilities.
3

(Optional) Custom Agent

# Use a custom agent configuration
praisonai bot slack --token $SLACK_BOT_TOKEN --app-token $SLACK_APP_TOKEN --agent agents.yaml
agents.yaml:
name: support-bot
instructions: |
  You are a customer support assistant.
  Be helpful and concise.
llm: gpt-4o-mini
tools:
  - search_web

Supported Platforms

ToolPlatformEnv Variable
SlackToolSlackSLACK_TOKEN
DiscordToolDiscordDISCORD_BOT_TOKEN or webhook URL
TelegramToolTelegramTELEGRAM_BOT_TOKEN
WhatsAppToolWhatsApp BusinessWHATSAPP_TOKEN, WHATSAPP_PHONE_ID
SignalToolSignalRequires signal-cli daemon
LineToolLINELINE_CHANNEL_ACCESS_TOKEN
iMessageTooliMessage (macOS only)No token needed
TwilioToolSMS/VoiceTWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN
WebexToolWebexWEBEX_ACCESS_TOKEN
XToolX (Twitter)X_API_KEY, X_API_SECRET
EmailToolEmail (Gmail/SMTP)EMAIL_USERNAME, EMAIL_PASSWORD
These tools are from praisonai-tools for sending outbound messages from agents. For receiving messages via bot runtime, use the CLI or Python SDK shown above.Install: pip install praisonai-tools

How It Works

ComponentRole
PlatformTelegram, Discord, or Slack
BotMessage router and formatter
AgentAI processing and response
UserEnd user on messaging app

Socket Mode vs Webhook

PraisonAI bots support two connection modes:
ModeUse CaseRequirements
Socket ModeLocal development, behind firewallApp Token only
Webhook ModeProduction, high scalePublic URL with HTTPS
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

from praisonaiagents import BotConfig

config = BotConfig(
    token="bot-token",              # Bot authentication token
    webhook_url=None,               # Webhook URL (optional)
    command_prefix="/",             # Command prefix
    mention_required=True,          # Require @mention in groups
    typing_indicator=True,          # Show typing indicator
    max_message_length=4096,        # Max message length
    allowed_users=[],               # Allowed user IDs (empty = all)
    allowed_channels=[],            # Allowed channel IDs
    reply_in_thread=False,          # Reply in threads (default: inline)
    thread_threshold=500,           # Auto-thread if response > N chars (0 = disabled)
)
OptionTypeDefaultDescription
tokenstr""Bot authentication token
webhook_urlstrNoneWebhook URL for webhook mode
command_prefixstr"/"Prefix for bot commands
mention_requiredboolTrueRequire @mention in channels (DMs never require mention)
typing_indicatorboolTrueShow typing indicator
max_message_lengthint4096Max message length
allowed_userslist[]Allowed user IDs
allowed_channelslist[]Allowed channel IDs
timeoutint30Request timeout
reply_in_threadboolFalseAlways reply in threads
thread_thresholdint500Auto-thread responses longer than N chars (0 = disabled)
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

CLI Capabilities

Enable powerful agent features directly from the command line:

Memory

praisonai bot slack --memory
Bot remembers previous conversations

Knowledge/RAG

praisonai bot slack --knowledge \
  --knowledge-sources docs.pdf manual.txt
Answer from your documents

Skills

praisonai bot slack --skills researcher writer
Load named skill modules

Extended Thinking

praisonai bot slack --thinking high
Enable reflection mode (off/minimal/low/medium/high)
FlagDescriptionExample
--memoryEnable conversation memory--memory
--memory-providerMemory backend--memory-provider chroma
--knowledgeEnable RAG/knowledge--knowledge
--knowledge-sourcesSource files--knowledge-sources file.pdf
--skillsSkill modules--skills researcher
--thinkingThinking mode--thinking high
--webEnable web search--web
--web-providerSearch provider--web-provider duckduckgo
--browserEnable browser--browser
--toolsNamed tools--tools WikipediaTool
--sandboxSandbox mode--sandbox
--auto-approveAuto-approve tools--auto-approve

Platform Setup

  1. Message @BotFather on Telegram
  2. Send /newbot and follow prompts
  3. Copy the bot token
export TELEGRAM_BOT_TOKEN="123456:ABC-DEF..."
praisonai bot telegram --token $TELEGRAM_BOT_TOKEN

Bot Commands

Built-in commands users can send:
CommandDescription
/helpShow available commands
/statusCheck bot status
/resetReset conversation
/modelShow current model
Custom commands are automatically created from agent tools.

Common Patterns

from praisonaiagents import BotConfig

config = BotConfig(
    token="your-token",
    allowed_users=["user123", "user456"],
    allowed_channels=["channel789"]
)

CLI Commands

# Start Telegram bot
praisonai bot telegram --token $TOKEN

# Start Discord bot
praisonai bot discord --token $TOKEN

# Start Slack bot  
praisonai bot slack --token $TOKEN --app-token $APP_TOKEN

# With agent configuration
praisonai bot telegram --token $TOKEN --agent agents.yaml
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.

Docker Deployment

Deploy bots using Docker for production environments:
# Create .env file
cat > .env << EOF
OPENAI_API_KEY=your-openai-key
SLACK_BOT_TOKEN=xoxb-your-slack-bot-token
SLACK_APP_TOKEN=xapp-your-slack-app-token
EOF

# Run with docker compose
docker compose up slack-bot -d

# View logs
docker compose logs -f slack-bot
docker-compose.yml:
version: '3.8'
services:
  slack-bot:
    image: python:3.11-slim
    environment:
      OPENAI_API_KEY: ${OPENAI_API_KEY}
      SLACK_BOT_TOKEN: ${SLACK_BOT_TOKEN}
      SLACK_APP_TOKEN: ${SLACK_APP_TOKEN}
    command: >
      bash -c "pip install praisonai slack-bolt slack-sdk &&
               praisonai bot slack"
    restart: unless-stopped
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:
from praisonaiagents import BotConfig
from praisonai.bots import SlackBot

config = BotConfig(
    token="xoxb-your-slack-bot-token",
    webhook_url="https://your-domain.com",
    webhook_path="/slack/events"
)

bot = SlackBot(config=config)
bot.start()  # Listens on /slack/events
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

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.
Configure retry_attempts and implement exponential backoff for API rate limits.

Multi-Agent Configuration

You can also define multiple agents in an agents.yaml file for complex workflows: agents.yaml:
agents:
  searcher:
    name: Researcher
    role: Web Researcher
    goal: Search the web for relevant information on the given topic
    instructions: |
      Search the web thoroughly for information on the user's query.
      Return comprehensive, accurate results with sources.
    tools:
      - search_web

  summarizer:
    name: Summarizer
    role: Content Summarizer
    goal: Create clear, concise summaries of information
    instructions: |
      Take the research findings and create a well-structured summary.
      Highlight key points and insights.
      Keep it concise but informative.