-
-
Notifications
You must be signed in to change notification settings - Fork 40.1k
Closed
Closed
Copy link
Labels
enhancementNew feature or requestNew feature or request
Description
Summary
Request for hooks that allow plugins to intercept and modify messages before they reach the AI model and after the AI responds but before delivery to the user.
Use Case: Privacy/PII Anonymization
Building a privacy layer plugin that needs to:
- On message_received: Anonymize names, identifiers, addresses, etc. before sending to the AI API
- On message_sending: De-anonymize placeholders in AI responses before displaying to user
This keeps sensitive PII out of API logs while maintaining a seamless user experience. Useful for any regulated industry or privacy-conscious deployment.
Current State
The hooks documentation lists these as "Future Events (Planned)":
message:sent: When a message is sentmessage:received: When a message is received
The plugin API doesn't currently expose api.registerHook() for message events.
Proposed API
// In plugin register function
api.registerHook('message_received', (ctx) => {
// ctx.message.text = anonymize(ctx.message.text);
});
api.registerHook('message_sending', (ctx) => {
// ctx.message.text = deanonymize(ctx.message.text);
});Implementation Notes
- Hooks should be synchronous or support async with reasonable timeout
- Should fire for all channels (Telegram, WhatsApp, etc.)
- Should include context like channel, sender, session
- Order of hook execution should be deterministic
Workarounds Considered
- Pre-processing files before each task (partial solution, doesn't cover chat)
- Modifying channel plugins directly (not maintainable)
Happy to help test once available.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request