-
-
Notifications
You must be signed in to change notification settings - Fork 52.7k
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Feature Request
Add a message:received hook event that fires before the agent processes an incoming message. This would enable pre-processing workflows like:
- Fetching thread context for Slack/Discord before the agent responds
- Enriching messages with external data
- Filtering or transforming messages before agent processing
- Adding metadata or context injection
Use Case
When an agent is tagged in a Slack thread, OpenClaw currently only provides the root message + current message. The agent cannot see the thread history, leading to context-blind responses.
With a message:received hook, we could:
- Detect if the message is in a thread
- Fetch full thread history via Slack API
- Inject that context before the agent processes
Proposed API
const handler: HookHandler = async (event) => {
if (event.type !== 'message' || event.action !== 'received') return;
const { channel, threadId, channelId } = event.context;
if (channel === 'slack' && threadId) {
// Fetch thread replies
const replies = await fetchSlackThreadReplies(channelId, threadId);
// Inject into context
event.context.threadContext = replies;
}
};Current Workaround
Manual script call in agent instructions (AGENTS.md):
scripts/slack_thread_replies.sh <channel_id> <thread_ts> 30This is error-prone as it relies on the agent remembering to call it.
Related
- Docs mention
message:receivedas a planned event: https://docs.openclaw.ai/automation/hooks - Related bug: message(action=read, threadId=X) returns channel messages instead of thread replies #12866 (threadId parameter not working in message read action)
Environment
- OpenClaw version: 2026.2.6-3
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request