DM Pairing System
The DM pairing system provides explicit owner approval for who is allowed to send direct messages to your SimpleClaw assistant. When enabled, unknown senders receive a pairing code and their messages are held until you approve them.How DM Pairing Works
Pairing Flow
- Unknown sender messages your assistant: A sender not in your allowlist sends a message
- Pairing code generated: SimpleClaw generates an 8-character pairing code
- Code sent to sender: The sender receives the pairing code (not their message)
- Owner approves: You review the pending request and approve it with the code
- Sender added to allowlist: Once approved, the sender can message your assistant normally
Pairing Code Format
- Length: 8 characters
- Character set: Uppercase letters and numbers (A-Z, 2-9)
- Excluded characters: No ambiguous characters (
0,O,1,I) - Example:
AB3K9PQR
Code Expiration
- Pairing codes expire after 1 hour
- SimpleClaw only sends the pairing message when a new request is created
- If the code expires, the sender must send another message to get a new code
- Pending requests are capped at 3 per channel by default
- Additional requests are ignored until existing ones expire or are approved
DM Policy Modes
SimpleClaw supports multiple DM access policies:pairing (Default)
- Behavior: Unknown senders get a pairing code and must be explicitly approved
- Use case: Personal assistant with controlled access
- Security: High - explicit approval required
allowlist
- Behavior: Only pre-configured senders in
allowFromlist can message - Use case: Locked-down environments with known users only
- Security: Highest - no pairing flow, hard allowlist only
open
- Behavior: All senders can message without approval
- Use case: Public bots or fully trusted environments
- Security: Low - no access control
disabled
- Behavior: All direct messages are blocked
- Use case: Group-only bots
- Security: High - DMs completely disabled
CLI Commands
List Pending Pairing Requests
View all pending pairing requests for a channel:Approve a Pairing Request
Approve a sender using their pairing code:- Added to the channel’s allowlist store
- Can send messages normally
- Persisted across SimpleClaw restarts
Supported Channels
Pairing is supported on these channels:telegramwhatsappsignalimessagediscordslackfeishu
Storage
Pairing state is stored under~/.simpleclaw/credentials/:
Pending Requests
- File:
<channel>-pairing.json - Format: Array of pending pairing requests
- Data:
id: Sender identifiercode: 8-character pairing codecreatedAt: ISO timestamp when request was createdlastSeenAt: ISO timestamp when sender last attempted to messagemeta: Optional metadata (account ID, etc.)
~/.simpleclaw/credentials/telegram-pairing.json
Approved Allowlist
- File:
<channel>-allowFrom.json - Format: Array of approved sender IDs
- Scope: Can be channel-level or account-level
~/.simpleclaw/credentials/telegram-allowFrom.json
Account-Scoped Allowlists
For channels with multiple accounts, allowlists can be scoped:- Format:
<channel>-<accountId>-allowFrom.json - Example:
whatsapp-15551234567-allowFrom.json - Backward compatibility: Legacy channel-level allowlists are still honored
Security Considerations
Treat as Sensitive
Pairing files gate access to your assistant:- Store
*-pairing.jsonand*-allowFrom.jsonas sensitive - Protect
~/.simpleclaw/credentials/with proper file permissions - Do not share pairing codes publicly
Pairing Code Security
- Codes are cryptographically random (using
crypto.randomInt()) - Collision resistance: Up to 500 attempts to generate unique code
- Codes are uppercase-only for easy manual entry
- No ambiguous characters to prevent transcription errors
File Locking
The pairing store uses file locking to prevent race conditions:- Lock retries: 10 attempts with exponential backoff
- Stale lock timeout: 30 seconds
- Atomic writes via
writeJsonFileAtomically()
Auto-Pruning
Pending requests are automatically cleaned:- Expired requests: Removed after 1 hour
- Excess requests: Only most recent 3 kept per channel
- Pruning happens during:
- List operations
- Approval operations
- New pairing request creation
Device Pairing
SimpleClaw also supports device pairing for nodes (iOS/Android/remote devices). This is separate from DM pairing.Device Pairing Flow
- Node connects to Gateway and requests pairing
- Gateway stores pending request and emits
node.pair.requestedevent - Owner approves via CLI or UI
- Gateway issues new authentication token
- Node reconnects with token and is now paired
Device Pairing via Telegram
You can pair devices entirely from Telegram using thedevice-pair plugin:
- In Telegram:
/pair - Bot sends setup code (base64-encoded JSON with URL and token)
- On device: Paste setup code in SimpleClaw app → Settings → Gateway
- Back in Telegram:
/pair approve
Device Pairing Storage
Stored under~/.simpleclaw/devices/:
pending.json: Pending device pairing requests (expire after 5 minutes)paired.json: Paired devices with authentication tokens
Device Pairing Commands
Integration with Allowlists
When you approve a pairing request:- Request is removed from
<channel>-pairing.json - Sender ID is added to
<channel>-allowFrom.json(or account-scoped variant) - Future messages from that sender are allowed without pairing