mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-09-27 04:18:35 +02:00
Catch Slack Greeting Msgs Generic (#1633)
This commit is contained in:
@@ -57,6 +57,20 @@ from shared_configs.configs import MODEL_SERVER_PORT
|
||||
logger = setup_logger()
|
||||
|
||||
|
||||
# In rare cases, some users have been experiencing a massive amount of trivial messages coming through
|
||||
# to the Slack Bot with trivial messages. Adding this to avoid exploding LLM costs while we track down
|
||||
# the cause.
|
||||
_SLACK_GREETINGS_TO_IGNORE = {
|
||||
"Welcome back!",
|
||||
"It's going to be a great day.",
|
||||
"Salutations!",
|
||||
"Greetings!",
|
||||
"Feeling great!",
|
||||
"Hi there",
|
||||
":wave:",
|
||||
}
|
||||
|
||||
|
||||
def prefilter_requests(req: SocketModeRequest, client: SocketModeClient) -> bool:
|
||||
"""True to keep going, False to ignore this Slack request"""
|
||||
if req.type == "events_api":
|
||||
@@ -78,6 +92,19 @@ def prefilter_requests(req: SocketModeRequest, client: SocketModeClient) -> bool
|
||||
channel_specific_logger.error("Cannot respond to empty message - skipping")
|
||||
return False
|
||||
|
||||
if (
|
||||
msg in _SLACK_GREETINGS_TO_IGNORE
|
||||
or remove_danswer_bot_tag(msg, client=client.web_client)
|
||||
in _SLACK_GREETINGS_TO_IGNORE
|
||||
):
|
||||
channel_specific_logger.error(
|
||||
f"Ignoring weird Slack greeting message: '{msg}'"
|
||||
)
|
||||
channel_specific_logger.error(
|
||||
f"Weird Slack greeting message payload: '{req.payload}'"
|
||||
)
|
||||
return False
|
||||
|
||||
# Ensure that the message is a new message of expected type
|
||||
event_type = event.get("type")
|
||||
if event_type not in ["app_mention", "message"]:
|
||||
|
Reference in New Issue
Block a user