diff --git a/backend/ee/onyx/onyxbot/slack/handlers/handle_standard_answers.py b/backend/ee/onyx/onyxbot/slack/handlers/handle_standard_answers.py index c2149f7a94a..9092c781c3c 100644 --- a/backend/ee/onyx/onyxbot/slack/handlers/handle_standard_answers.py +++ b/backend/ee/onyx/onyxbot/slack/handlers/handle_standard_answers.py @@ -206,7 +206,7 @@ def _handle_standard_answers( restate_question_blocks = get_restate_blocks( msg=query_msg.message, - is_bot_msg=message_info.is_bot_msg, + is_slash_command=message_info.is_slash_command, ) answer_blocks = build_standard_answer_blocks( diff --git a/backend/onyx/onyxbot/slack/blocks.py b/backend/onyx/onyxbot/slack/blocks.py index a40696a3303..c738f47c6e2 100644 --- a/backend/onyx/onyxbot/slack/blocks.py +++ b/backend/onyx/onyxbot/slack/blocks.py @@ -151,7 +151,7 @@ def _build_ephemeral_publication_block( email=message_info.email, sender_id=message_info.sender_id, thread_messages=[], - is_bot_msg=message_info.is_bot_msg, + is_slash_command=message_info.is_slash_command, is_bot_dm=message_info.is_bot_dm, thread_to_respond=respond_ts, ) @@ -225,10 +225,10 @@ def _build_doc_feedback_block( def get_restate_blocks( msg: str, - is_bot_msg: bool, + is_slash_command: bool, ) -> list[Block]: # Only the slash command needs this context because the user doesn't see their own input - if not is_bot_msg: + if not is_slash_command: return [] return [ @@ -576,7 +576,7 @@ def build_slack_response_blocks( # If called with the OnyxBot slash command, the question is lost so we have to reshow it if not skip_restated_question: restate_question_block = get_restate_blocks( - message_info.thread_messages[-1].message, message_info.is_bot_msg + message_info.thread_messages[-1].message, message_info.is_slash_command ) else: restate_question_block = [] diff --git a/backend/onyx/onyxbot/slack/handlers/handle_buttons.py b/backend/onyx/onyxbot/slack/handlers/handle_buttons.py index 2669f315245..c01d4c439f5 100644 --- a/backend/onyx/onyxbot/slack/handlers/handle_buttons.py +++ b/backend/onyx/onyxbot/slack/handlers/handle_buttons.py @@ -177,7 +177,7 @@ def handle_generate_answer_button( sender_id=user_id or None, email=email or None, bypass_filters=True, - is_bot_msg=False, + is_slash_command=False, is_bot_dm=False, ), slack_channel_config=slack_channel_config, diff --git a/backend/onyx/onyxbot/slack/handlers/handle_message.py b/backend/onyx/onyxbot/slack/handlers/handle_message.py index fc6bd23d60c..cad8799eef1 100644 --- a/backend/onyx/onyxbot/slack/handlers/handle_message.py +++ b/backend/onyx/onyxbot/slack/handlers/handle_message.py @@ -28,7 +28,7 @@ def send_msg_ack_to_user(details: SlackMessageInfo, client: WebClient) -> None: - if details.is_bot_msg and details.sender_id: + if details.is_slash_command and details.sender_id: respond_in_thread_or_channel( client=client, channel=details.channel_to_respond, @@ -124,11 +124,11 @@ def handle_message( messages = message_info.thread_messages sender_id = message_info.sender_id bypass_filters = message_info.bypass_filters - is_bot_msg = message_info.is_bot_msg + is_slash_command = message_info.is_slash_command is_bot_dm = message_info.is_bot_dm action = "slack_message" - if is_bot_msg: + if is_slash_command: action = "slack_slash_message" elif bypass_filters: action = "slack_tag_message" @@ -197,7 +197,7 @@ def handle_message( # If configured to respond to team members only, then cannot be used with a /OnyxBot command # which would just respond to the sender - if send_to and is_bot_msg: + if send_to and is_slash_command: if sender_id: respond_in_thread_or_channel( client=client, diff --git a/backend/onyx/onyxbot/slack/handlers/handle_regular_answer.py b/backend/onyx/onyxbot/slack/handlers/handle_regular_answer.py index be8ad4136fb..7818b70edec 100644 --- a/backend/onyx/onyxbot/slack/handlers/handle_regular_answer.py +++ b/backend/onyx/onyxbot/slack/handlers/handle_regular_answer.py @@ -81,15 +81,15 @@ def handle_regular_answer( messages = message_info.thread_messages message_ts_to_respond_to = message_info.msg_to_respond - is_bot_msg = message_info.is_bot_msg + is_slash_command = message_info.is_slash_command # Capture whether response mode for channel is ephemeral. Even if the channel is set # to respond with an ephemeral message, we still send as non-ephemeral if # the message is a dm with the Onyx bot. send_as_ephemeral = ( slack_channel_config.channel_config.get("is_ephemeral", False) - and not message_info.is_bot_dm - ) + or message_info.is_slash_command + ) and not message_info.is_bot_dm # If the channel mis configured to respond with an ephemeral message, # or the message is a dm to the Onyx bot, we should use the proper onyx user from the email. @@ -164,7 +164,7 @@ def handle_regular_answer( # in an attached document set were available to all users in the channel.) bypass_acl = False - if not message_ts_to_respond_to and not is_bot_msg: + if not message_ts_to_respond_to and not is_slash_command: # if the message is not "/onyx" command, then it should have a message ts to respond to raise RuntimeError( "No message timestamp to respond to in `handle_message`. This should never happen." @@ -316,13 +316,14 @@ def _get_slack_answer( return True # Got an answer at this point, can remove reaction and give results - update_emote_react( - emoji=DANSWER_REACT_EMOJI, - channel=message_info.channel_to_respond, - message_ts=message_info.msg_to_respond, - remove=True, - client=client, - ) + if not is_slash_command: # Slash commands don't have reactions + update_emote_react( + emoji=DANSWER_REACT_EMOJI, + channel=message_info.channel_to_respond, + message_ts=message_info.msg_to_respond, + remove=True, + client=client, + ) if answer.answer_valid is False: logger.notice( diff --git a/backend/onyx/onyxbot/slack/listener.py b/backend/onyx/onyxbot/slack/listener.py index a20091a1442..97829bd3e96 100644 --- a/backend/onyx/onyxbot/slack/listener.py +++ b/backend/onyx/onyxbot/slack/listener.py @@ -876,12 +876,13 @@ def build_request_details( sender_id=sender_id, email=email, bypass_filters=tagged, - is_bot_msg=False, + is_slash_command=False, is_bot_dm=event.get("channel_type") == "im", ) elif req.type == "slash_commands": channel = req.payload["channel_id"] + channel_name = req.payload["channel_name"] msg = req.payload["text"] sender = req.payload["user_id"] expert_info = expert_info_from_slack_id( @@ -899,8 +900,8 @@ def build_request_details( sender_id=sender, email=email, bypass_filters=True, - is_bot_msg=True, - is_bot_dm=False, + is_slash_command=True, + is_bot_dm=channel_name == "directmessage", ) raise RuntimeError("Programming fault, this should never happen.") diff --git a/backend/onyx/onyxbot/slack/models.py b/backend/onyx/onyxbot/slack/models.py index 1bba86119d3..4079a8c1124 100644 --- a/backend/onyx/onyxbot/slack/models.py +++ b/backend/onyx/onyxbot/slack/models.py @@ -13,7 +13,7 @@ class SlackMessageInfo(BaseModel): sender_id: str | None email: str | None bypass_filters: bool # User has tagged @OnyxBot - is_bot_msg: bool # User is using /OnyxBot + is_slash_command: bool # User is using /OnyxBot is_bot_dm: bool # User is direct messaging to OnyxBot @@ -25,7 +25,7 @@ class ActionValuesEphemeralMessageMessageInfo(BaseModel): email: str | None sender_id: str | None thread_messages: list[ThreadMessage] | None - is_bot_msg: bool | None + is_slash_command: bool | None is_bot_dm: bool | None thread_to_respond: str | None