Skip to content

Slack: bot does not respond to direct messages (message.im channel type) #396

@antigenius0910

Description

@antigenius0910

Summary

The Slack adapter does not respond to direct messages (DMs). When a user sends a message directly to the bot, the bot is silent.

Root Cause

In src/slack.rs, the "message" event handler only processes messages that are already in a thread (has_thread && ...):

if has_thread && !is_bot && !skip_subtype && !mentions_bot {
    handle_message(...)
}

In DMs (message.im), the initial message has no thread_ts, so has_thread is false and the message is dropped silently. The app_mention branch also never fires in DMs because users cannot @mention the bot in a DM.

Affected Event Types

  • message with channel_type: "im" (DM channels, IDs start with D)

Proposed Fix

Detect DM channels via channel_type == "im" (or channel ID prefix D) and allow those messages through regardless of has_thread:

let channel_type = event["channel_type"].as_str().unwrap_or("");
let channel_id = event["channel"].as_str().unwrap_or("");
let is_dm = channel_type == "im" || channel_id.starts_with('D');

if (has_thread || is_dm) && !is_bot && !skip_subtype && !mentions_bot {
    handle_message(...)
}

Tracking

Part of #382

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions