Bot platform adapters now ship in the
praisonai-bot package. praisonai bot serve still works exactly as documented here; for a standalone install see praisonai-bot Migration.Quick Start
1
Enable Pairing Policy
2
Approve Pairing Requests
How It Works
The pairing flow now fires only when
BotConfig.is_explicitly_allowed(user_id) returns False (empty allowlist, or user not on it). Users on allowed_users skip pairing entirely — PR #2856.Policy Configuration
Unknown User Policies
Pairing Rate Limiting
The system includes built-in protection against code generation spam:- Rate Limit: 10 minutes between code generations per channel
- Code TTL: Codes expire after a configurable time (default: check
PaisingStoreimplementation) - Automatic Cleanup: Stale rate limit entries are automatically evicted
CLI Commands
List Commands
Approve Command
Revoke Access
Web-UI / HTTP API Approval
Approve, list, and revoke pairings from a web admin UI via the gateway’s HTTP API.Endpoints
- List Pending
- Approve Pairing
- Revoke Access
GET /api/pairing/pendingReturns pending pairing requests awaiting approval.
All three routes are gated by an admin auth checker (
auth_admin) wired in by create_pairing_routes(pairing_store, auth_admin). Non-admin sessions receive 403. Invalid codes return 404.Reacting to Pairing Approvals (EventBus)
Subscribe to thepairing_approved event to run agent logic the moment a channel is approved — for example, send a welcome DM, log to your CRM, or warm a per-user memory store.
Event Payload
Platform Support
Current Implementation
Platform Implementation Status: PR #1504 ships the pairing system and CLI with full Telegram support. Other platform adapters need handler wiring to complete the integration.
Telegram Integration
Security Model
Code Generation
- 8-character codes: Hex format (e.g.,
ABCD1234) - HMAC signatures: Codes are cryptographically signed
- Per-install secret: Auto-generated if
PRAISONAI_GATEWAY_SECRETunset - Channel binding: Codes can be bound to specific channel IDs
Secret Management
0o666 file left over from an older install is fixed automatically on the next startup — no manual chmod needed. See Security → PR #2850 for the hardening summary.
Security Features
- Rate Limiting: 600s (10 min) window per channel prevents spam
- HMAC Verification: Codes are cryptographically signed and verified
- TTL Expiration: Codes automatically expire after configured time
- Atomic Operations: Pairing state persisted atomically to disk
User Interaction Flow
Step-by-Step Process
-
Unknown User DMs Bot
-
Bot Generates Pairing Code
-
Owner Approves via CLI
-
User Can Now Interact Normally
Rate Limit Handling
If a user tries to generate codes too frequently:Configuration Options
Store Directory
Environment Variables
Best Practices
Production Secret Management
Production Secret Management
Set
PRAISONAI_GATEWAY_SECRET explicitly in production environments to ensure consistent code verification across deployments.Monitor Rate Limits
Monitor Rate Limits
Watch for rate limiting warnings in logs - they indicate potential pairing spam or legitimate users hitting limits.
Use Descriptive Labels
Use Descriptive Labels
Add labels when approving pairings to identify channels later.
Regular Pairing Audits
Regular Pairing Audits
Periodically review paired channels and revoke access for inactive users.
Pair a user with a non-empty
--label (the canonical id) and StoreBackedIdentityResolver automatically unifies their session across every channel paired under the same label. No separate praisonai identity link calls needed. See Cross-Platform Sessions › StoreBackedIdentityResolver.Related
Bot Security
Comprehensive bot security and DM policies
Messaging Bots
Bot platform setup and configuration
Cross-Platform Sessions
Unified per-user sessions across platforms

