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
Store Hardening (PraisonAI #3974)
PraisonAI #3974 hardens the pairing store without changing its public API — legacy plaintextpairing.json stores still load, so there is nothing to migrate.
At-rest hashing
Since #3974, only a salted SHA-256 of each pending code is written topairing.json. Reading the file never yields a usable code, and a rainbow table is useless without the per-install HMAC secret used as salt.
praisonai pairing list (or PairingStore.list_pending()) against a store whose code was created in another process returns entries with code: None and the code_hash — the pending request stays visible, the raw code does not.
Store-level brute-force lockout
verify_and_pair() counts failed verifications per channel_type and refuses further attempts once the ceiling trips — uniformly across every approval surface (HTTP route, in-chat Approve/Deny button, CLI praisonai pairing approve). Tune via constructor kwargs:
A success clears the counter; a valid HMAC presented against the wrong
channel_id does not (otherwise a repeated wrong-binding guess would reset the budget). Once locked out, even a valid code for that channel_type is refused until the cooldown expires — the lockout is store-level, not surface-level.
Log line to watch in operator dashboards:
Pairing verification locked out for channel_type=<type> (level WARNING).Unambiguous alphabet
Generated codes useABCDEFGHJKLMNPQRSTUVWXYZ23456789 — 8 characters, dropping 0/O/1/I so codes read aloud or retyped from another device are not mis-entered. Length is unchanged; entropy rises to log2(32^8) = 40 bits.
max_pending now counts entries rehydrated from disk, so repeated restarts can no longer grow pairing.json past the configured bound.Code Generation
- 8-character codes: Unambiguous alphabet
ABCDEFGHJKLMNPQRSTUVWXYZ23456789(drops0/O/1/I, since #3974) - HMAC signatures: Codes are cryptographically signed
- Hashed at rest: Only a salted SHA-256 of each code is persisted (since #3974)
- Per-install secret: Auto-generated if
PRAISONAI_GATEWAY_SECRETunset - Channel binding: Codes can be bound to specific channel IDs
Secret Management
Pairing codes and the inline Approve/Deny callback buttons share this one
persisted HMAC secret at
~/.praisonai/gateway/.gateway_secret. Both survive
gateway restarts by default — no operator action required. See
Unknown-User Pairing → HMAC-signed Callbacks
for the callback-button flow.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

