Repository: phidatahq/phidata
File: libs/agno/agno/os/interfaces/slack/router.py (Python)

Code before:
        if "event" in data:
            event = data["event"]
            if event.get("bot_id"):
                log_info("bot event")
                pass
            else:
                background_tasks.add_task(_process_slack_event, event)

        return SlackEventResponse(status="ok")

    async def _process_slack_event(event: dict):
        event_type = event.get("type")

        # Only handle app_mention and message events
        if event_type not in ("app_mention", "message"):
            return

        channel_type = event.get("channel_type", "")

        # Handle duplicate replies
        if not reply_to_mentions_only and event_type == "app_mention":
            return

        if reply_to_mentions_only and event_type == "message" and channel_type != "im":
            return

        # Extract event data
        user = None
        message_text = event.get("text", "")
        channel_id = event.get("channel", "")
        user = event.get("user")
        if event.get("thread_ts"):
            ts = event.get("thread_ts", "")
        else:
            ts = event.get("ts", "")

        # Use the timestamp as the session id, so that each thread is a separate session
        session_id = ts

        if agent:
            response = await agent.arun(message_text, user_id=user if user else None, session_id=session_id)
        elif team:
            response = await team.arun(message_text, user_id=user if user else None, session_id=session_id)  # type: ignore
        elif workflow:
            response = await workflow.arun(message_text, user_id=user if user else None, session_id=session_id)  # type: ignore

        if response:
            if hasattr(response, "reasoning_content") and response.reasoning_content:
                _send_slack_message(
                    channel=channel_id,
                    message=f"Reasoning: \n{response.reasoning_content}",

Review comment (suggestion):
```suggestion
        # If reply_to_mentions_only is True, ignore every message that is not a DM
        if reply_to_mentions_only and event_type == "message" and channel_type != "im":
            return
```

Code after:
        if "event" in data:
            event = data["event"]
            if event.get("bot_id"):
                log_info("bot event")
                pass
            else:
                background_tasks.add_task(_process_slack_event, event)

        return SlackEventResponse(status="ok")

    async def _process_slack_event(event: dict):
        event_type = event.get("type")

        # Only handle app_mention and message events
        if event_type not in ("app_mention", "message"):
            return

        channel_type = event.get("channel_type", "")

        # Handle duplicate replies
        if not reply_to_mentions_only and event_type == "app_mention":
            return

        # If reply_to_mentions_only is True, ignore every message that is not a DM
        if reply_to_mentions_only and event_type == "message" and channel_type != "im":
            return

        # Extract event data
        user = None
        message_text = event.get("text", "")
        channel_id = event.get("channel", "")
        user = event.get("user")
        if event.get("thread_ts"):
            ts = event.get("thread_ts", "")
        else:
            ts = event.get("ts", "")

        # Use the timestamp as the session id, so that each thread is a separate session
        session_id = ts

        if agent:
            response = await agent.arun(message_text, user_id=user, session_id=session_id)
        elif team:
            response = await team.arun(message_text, user_id=user, session_id=session_id)  # type: ignore
        elif workflow:
            response = await workflow.arun(message_text, user_id=user, session_id=session_id)  # type: ignore

        if response:
            if hasattr(response, "reasoning_content") and response.reasoning_content:
                _send_slack_message(
                    channel=channel_id,