- Recommended (with pairing)
- Explicit links only
How It Works
Quick Start
Choosing Your Resolver
StoreBackedIdentityResolver
StoreBackedIdentityResolver extends the core FileIdentityResolver with a read-through to the gateway pairing store, so users who have already paired share a session out of the box.
Resolution order:
- Explicit link registered via
link()(highest priority) - Pairing-store label for
(user_id, platform)when the channel is paired and carries a non-emptylabel f"{platform}:{user_id}"— safe per-platform fallback (no merging)
link_paired() — Promote Paired Users to Explicit Links
CLI: praisonai identity
Four subcommands manage identity links from the command line.| Command | Purpose |
|---|---|
praisonai identity link <platform> <user_id> <canonical> | Map a (platform, user_id) to a canonical identity |
praisonai identity unlink <platform> <user_id> | Remove a mapping |
praisonai identity list [canonical] | Show all links, or links for a single canonical id |
praisonai identity import | Materialise paired channels as explicit identity links |
| Option | Default | Description |
|---|---|---|
--path | ~/.praisonai/identity.json (or $PRAISONAI_IDENTITY_PATH) | Override the link-map JSON path |
--store-dir | gateway default | Override the pairing store directory |
SessionContext for Tools
Any tool the agent calls can read who is messaging:SessionContext Fields
| Field | Type | Description | |
|---|---|---|---|
platform | str | "telegram", "discord", "slack", … | |
chat_id | str | Platform chat / channel id | |
chat_name | str | Human-readable channel name | |
thread_id | str | Thread / topic id (Slack threads, Telegram topics) | |
user_id | str | Raw platform user id | |
user_name | str | Display name | |
unified_user_id | str | Result of IdentityResolver.resolve() | |
origin | Optional[Origin] | None | Platform-aware origin info — see Platform-Aware Agents |
reachable_targets | Optional[List[ReachableTarget]] | None | Channels the agent can deliver to — see Platform-Aware Agents |
Use
set_session_context / clear_session_context for advanced custom adapters. Returns a token; reset in a finally block.Mirror for Outbound Deliveries
Cron jobs, scheduled deliveries, and cross-platform replies need to mirror the assistant’s outbound message into the user’s history:Parameters
| Parameter | Type | Description |
|---|---|---|
session_mgr | BotSessionManager | Session manager instance |
user_id | str | Unified user ID |
message_text | str | Message content to mirror |
source_label | str | Source identifier ("cron", "web", "cross_platform") |
metadata | dict | Optional extra metadata |
lock | threading.RLock | Optional lock for synchronization |
Errors are swallowed and logged — a mirror failure must never break the outbound delivery itself.
Storage & Privacy
FileIdentityResolver defaults to ~/.praisonai/identity.json (override via PRAISONAI_IDENTITY_PATH env var or constructor path=). File is written atomically and chmod 0o600.Best Practices
Use StoreBackedIdentityResolver for production (with pairing)
Use StoreBackedIdentityResolver for production (with pairing)
For production wrapper deployments, use
StoreBackedIdentityResolver.from_env() — it picks up paired channels automatically and falls back to the same safe platform:user_id default. Plain FileIdentityResolver is the right choice only when you do not use the pairing system.Use FileIdentityResolver for explicit-only links
Use FileIdentityResolver for explicit-only links
For production single-host bots without pairing integration,
FileIdentityResolver provides persistent storage with atomic writes and proper file permissions.Implement custom IdentityResolverProtocol for scale
Implement custom IdentityResolverProtocol for scale
For multi-process/multi-host deployments, back it with SQLite, Redis, or a database:
Pair before linking
Pair before linking
Never auto-link based on display name. Always require a DM-verified pairing flow:
Read SessionContext in tools
Read SessionContext in tools
Instead of
os.environ, read SessionContext — concurrent message handlers won’t trample each other:Related
BotOS
Multi-platform bot orchestrator
Messaging Bots
Platform-specific bot guides
Bot Pairing
Secure unknown-user onboarding
Unknown-User Pairing
Inline-button approval for bots

