Skip to content

Commit 373ccd0

Browse files
committed
Update comments
1 parent 6544f9e commit 373ccd0

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

packages/slackBotFunction/app/slack/slack_events.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,15 @@ def process_async_slack_event(slack_event_data):
8181
thread_ts if context_type == "thread" else None,
8282
)
8383

84-
# 1) Post the answer (plain) to get message_ts
84+
# Post the answer (plain) to get message_ts
8585
post = client.chat_postMessage(
8686
channel=channel,
8787
text=response_text,
8888
thread_ts=thread_ts,
8989
)
9090
message_ts = post["ts"]
9191

92-
# 2) Attach feedback buttons via chat_update (value kept small; no user_query)
92+
# Attach feedback buttons via chat_update (value kept small; no user_query)
9393
feedback_value = json.dumps({"ck": conversation_key, "ch": channel, "tt": thread_ts, "mt": message_ts})
9494
blocks = [
9595
{"type": "section", "text": {"type": "mrkdwn", "text": response_text}},

packages/slackBotFunction/app/slack/slack_handlers.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ def setup_handlers(app):
309309

310310
def is_duplicate_event(event_id):
311311
"""
312-
Best-effort deduplication for Slack retries using DynamoDB conditional write.
312+
Check if we've already processed this event using DynamoDB conditional writes.
313313
314314
Key:
315315
pk = f"event#{event_id}", sk = "dedup", ttl = now + 1h
@@ -323,23 +323,23 @@ def is_duplicate_event(event_id):
323323
Item={"pk": f"event#{event_id}", "sk": "dedup", "ttl": ttl, "timestamp": int(time.time())},
324324
ConditionExpression="attribute_not_exists(pk)",
325325
)
326-
return False
326+
return False # Not a duplicate
327327
except ClientError as e:
328328
if e.response.get("Error", {}).get("Code") == "ConditionalCheckFailedException":
329-
return True
329+
return True # Duplicate
330330
logger.error(f"Error checking event duplication: {e}")
331331
return False
332332

333333

334334
def trigger_async_processing(event_data):
335335
"""
336-
Asynchronously re-invoke this Lambda for long-running work (e.g., model calls).
336+
Trigger asynchronous Lambda invocation to process Slack events.
337337
338-
Slack requires responses within ~3 seconds. To avoid timeouts, we:
339-
1) ack immediately in the handler,
340-
2) self-invoke the Lambda with InvocationType='Event',
341-
3) perform the heavy work in the async path and post back to Slack.
338+
Slack requires responses within 3 seconds, but Bedrock queries can take longer.
339+
This function invokes the same Lambda function asynchronously to handle the
340+
actual AI processing without blocking the initial Slack response.
342341
"""
342+
# incase we fail to re-invoke the lambda we should log an error
343343
try:
344344
lambda_client = boto3.client("lambda")
345345
lambda_client.invoke(

0 commit comments

Comments
 (0)