Bot security enables safe deployment of PraisonAI agents across messaging channels with built-in protection against abuse and unauthorized access.Documentation Index
Fetch the complete documentation index at: https://docs.praison.ai/llms.txt
Use this file to discover all available pages before exploring further.
Quick Start
How It Works
| Component | Purpose | Status |
|---|---|---|
| Allowlist | Control access | Conceptual |
| DM Policy | Message filtering | Conceptual |
| Pairing | Channel authorization | Conceptual |
Security Model
OpenClaw-style security for messaging bots. This guide covers DM pairing, allowlists, and safe defaults across Telegram, Discord, Slack, WhatsApp, and other channels.
Safe Defaults by Channel
Telegram
Recommended production config:- ✅ User allowlist by username or ID
- ✅ Group mention-only policy
- ✅ Built-in command filtering
- ⚠️ DMs from unknown users are processed by default
Discord
Recommended production config:- ✅ User/guild allowlist support
- ✅ Role-based restrictions
- ✅ Thread-safe message handling
- ⚠️ DMs from unknown users are processed by default
Slack
Recommended production config:- ✅ User/channel allowlist
- ✅ Enterprise Grid support
- ✅ Socket mode security
- ✅ Built-in DM filtering (mentions required)
- ✅ Strong default security - allowlist required for DMs
- ✅ Phone number + group allowlists
- ✅ Built-in self-chat detection
- ✅ Automatic spam filtering
Owner-DM Pairing
The pairing system is now shipped and enables owner-approval for unknown users with inline Approve/Deny buttons sent directly to your DM. For production deployments, use owner-DM pairing to authorize unknown users dynamically:1. Set Callback Secret
2. Configure Unknown User Policy
3. Owner Approval Workflow
When an unknown user messages your bot:- Bot generates a pairing code
- Owner receives DM with inline Approve/Deny buttons
- Owner clicks Approve → User is permanently approved
- Owner clicks Deny → Request is rejected
owner_user_id is not set, the bot replies:
4. Manual Approval (CLI)
Owners can approve pairing requests manually:Gateway Pairing
For production deployments, use gateway pairing to authorize channels dynamically with the shipped pairing system:The gateway secret is optional - if unset, a per-install secret is auto-generated at
<store_dir>/.gateway_secret with 0600 permissions and reused across restarts.Enable Pairing Policy
Approve Pairing Requests
When unknown users DM your bot, they receive pairing codes. Approve them via CLI:Manage Pairings
List Pending Requests
List all pending pairing codes waiting for approval:| Key | Type | Source | Notes |
|---|---|---|---|
code | str | canonical | 8-char pairing code |
channel_type | str | canonical | e.g. "telegram", "discord", "slack", "whatsapp" |
channel_id | str | None | canonical | Bound channel id if code was generated with one |
created_at | float | canonical | Unix timestamp (seconds) when code was generated |
channel | str | UI alias | Same value as channel_type, kept for UI banner compatibility |
user_id | str | UI alias | Currently equals code (see note in approve() docstring) |
user_name | str | UI alias | Formatted as "User {code}" |
age_seconds | int | UI alias | int(now - created_at) |
Canonical keys (
code, channel_type, channel_id, created_at) are the stable contract. The channel, user_id, user_name, and age_seconds aliases are provided for UI consumers and should not be relied on for scripting — use the canonical keys.CLI Commands
Use thepraisonai pairing commands to manage pairings from the command line:
| Command | Purpose | Required Args |
|---|---|---|
praisonai pairing list | List all paired channels | — |
praisonai pairing approve PLATFORM CODE [CHANNEL_ID] | Approve an 8-char pairing code | platform, code |
praisonai pairing revoke PLATFORM CHANNEL_ID | Revoke a paired channel | platform, channel_id |
praisonai pairing clear | Clear all paired channels | — |
telegram, discord, slack, whatsapp
Pairing Flow:
7. REST API
The gateway exposes REST endpoints for pairing management:| Method | Path | Body / Query | Response | Auth Required |
|---|---|---|---|---|
GET | /api/pairing/pending | — | list_pending() schema | ✅ |
POST | /api/pairing/approve | { "channel": str, "code": str } | { "approved": true, ... } | ✅ |
POST | /api/pairing/revoke | { "channel": str, "user_id": str } | { "revoked": true, ... } | ✅ |
All endpoints are authenticated and rate-limited. Rate limits are applied per client IP with separate buckets for
pairing_pending, pairing_approve, and pairing_revoke operations.Doctor Security Check
Use the built-in doctor to audit your bot security configuration:- ❌ Missing allowlists - channels without allowlist/blocklist
- ⚠️ Permissive group policies -
respond_allin production - ⚠️ Missing gateway secret - pairing codes won’t persist
- ✅ Secure configuration - allowlists + mention-only policies
Self-Hoster Security Checklist
Before going public with your bot:✅ DM Policy Configured
✅ DM Policy Configured
- Allowlist configured for each channel
- Unknown sender behavior defined (block/ignore/process)
- Group policies set to
mention_onlyorcommand_only - Blocklist configured for known spam sources
✅ Gateway Pairing Active
✅ Gateway Pairing Active
-
PRAISONAI_GATEWAY_SECRETset -
PRAISONAI_CALLBACK_SECRETset (for inline buttons) -
unknown_user_policyconfigured (deny/pair/allow) -
owner_user_idset for inline approvals - Pairing workflow tested and verified
- Revocation process documented
✅ Tool Approval Enabled
✅ Tool Approval Enabled
- Dangerous tools require approval (not auto-approved)
- Approval backend configured (Slack/Telegram/HTTP)
- Tool risk levels reviewed and appropriate
- Approval timeout configured
✅ Monitoring & Alerts
✅ Monitoring & Alerts
- Bot security doctor check passing
- Audit logging enabled (
praisonai.security.enable_audit_log) - Injection defense active (
praisonai.security.enable_injection_defense) - Rate limiting configured for API calls
✅ Infrastructure Security
✅ Infrastructure Security
- Bot tokens stored securely (not in code)
- Environment variables encrypted at rest
- Network access restricted (firewall rules)
- Regular security updates scheduled
Common Security Patterns
1. Staged Rollout
Start with restrictive settings and gradually open access:2. Multi-Channel Allowlist
Maintain consistent allowlists across channels:3. Environment-Based Security
Different security levels per environment:Security Headers & API Protection
When running bot gateways, enable security headers:Advanced: Custom Security Hooks
Implement custom security logic with hooks:Troubleshooting
Pairing Issues
Problem: Pairing codes not working Solution:- Check
PRAISONAI_GATEWAY_SECRETis set - Verify code hasn’t expired (5 min default)
- Ensure code typed exactly (case sensitive)
- Set
PRAISONAI_GATEWAY_SECRETenv var - Codes without persistent secret are temporary
praisonai pairing approve reports “Invalid or expired code” even though a code was just generated from the UI
Solution:
- Upgrade to the latest
praisonaiversion (fix included in 2026-04-22 release) - Older builds had a duplicate internal method that stripped the canonical
codekey when the UI pairing banner was loaded
Allowlist Issues
Problem: Bot not responding to allowed users Solution:- Check exact user ID format (username vs numeric ID)
- Verify allowlist syntax in YAML
- Run
praisonai doctorfor validation
- Check allowlist is configured (not just blocklist)
- Verify
group_policysetting - Check if user has alternate access path
Best Practices
✅ Allowlist Management
✅ Allowlist Management
- Use explicit allowlists for all channels
- Regularly review and update allowed users
- Implement role-based access where possible
- Log all access attempts for audit trails
🔐 Secret Management
🔐 Secret Management
- Store tokens in environment variables
- Rotate secrets regularly
- Use encrypted storage for sensitive data
- Never commit secrets to version control
⚡ Rate Limiting
⚡ Rate Limiting
- Implement per-user rate limits
- Set global request quotas
- Monitor for unusual activity patterns
- Implement exponential backoff for failed requests
📊 Monitoring
📊 Monitoring
- Enable audit logging
- Monitor security events
- Set up alerting for suspicious activity
- Regular security reviews
Related
Agent Configuration
Core agent setup and configuration
Gateway Setup
Multi-channel gateway configuration
By following these security practices, your PraisonAI bots will operate safely in production while maintaining the flexibility to serve legitimate users. Regular security audits help ensure your configuration stays secure over time.

