Quick Start
1
Use a built-in slash-command button (zero config)
Buttons wired to slash commands fire automatically — no handler registration needed.When the user taps Get Help, the existing
/help handler fires automatically via the built-in command namespace.2
Register a custom namespace handler
For your own button logic, create a registry and register an async handler.
encode_action("approval", ...) produces "approval:yes" / "approval:no". When a user taps the button, registry.dispatch() routes the click to on_approval.How It Works
Decoding Rules
decode_callback(data) maps raw callback_data to a (namespace, payload) tuple:
After
dispatch(), the registry also writes decoded_namespace and decoded_payload into ctx.platform_data before calling your handler.
Choosing a Namespace Style
Platform-Specific Context
Each adapter populatesctx.platform_data with native objects so you can access full platform functionality inside your handler.
Telegram
Telegram
Access example:
Discord
Discord
Access example:
Slack
Slack
Access example:
Common Patterns
- Yes / No approval
API Reference
InteractiveContext
Passed to every handler by the registry’s dispatch() method.
After
dispatch(), platform_data also contains:
decoded_namespace— the decoded namespace stringdecoded_payload— the decoded payload dict
InteractiveHandler
None string to mark the click as handled (stops the chain). Return None to fall through to the fallback handler.
InteractiveRegistry
Functions
Built-in Namespaces
Every platform adapter (Telegram, Discord, Slack) registers these automatically:Best Practices
Use create_registry() per adapter
Use create_registry() per adapter
Each bot adapter should have its own registry to prevent namespace collisions when running multiple bots in the same process.
Always set PRAISONAI_CALLBACK_SECRET in production
Always set PRAISONAI_CALLBACK_SECRET in production
Inline-button callbacks are HMAC-signed. Without a persistent secret, callbacks fail after every bot restart.
Return non-None only when you handled the click
Return non-None only when you handled the click
Returning
None lets the fallback handler run. This is useful when one namespace handler is shared across multiple button types and you only want to handle specific values.Catch your own exceptions inside the handler
Catch your own exceptions inside the handler
Unhandled exceptions inside a handler are logged, but the registry will still try the fallback. Users won’t see a useful error message unless you handle it yourself.
Related
Messaging Bots
Complete bot configuration and platform setup
Unknown-User Pairing
Owner-approval flow for new users using the pair namespace

