Skip to content

Feature request: message:received hook for pre-processing incoming messages #12867

@visshehi

Description

@visshehi

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:

  1. Detect if the message is in a thread
  2. Fetch full thread history via Slack API
  3. 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> 30

This is error-prone as it relies on the agent remembering to call it.

Related

Environment

  • OpenClaw version: 2026.2.6-3

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions