-
-
Save KyMidd/d8f73cc55839d99a19a7bb5a83b274ff to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Common function to handle both DMs and app mentions | |
| def handle_message_event(client, body, say, bedrock_client, app, token): | |
| user_id = body["event"]["user"] | |
| event = body["event"] | |
| # Determine the thread timestamp | |
| thread_ts = body["event"].get("thread_ts", body["event"]["ts"]) | |
| # Initialize conversation context | |
| conversation = [] | |
| # Check to see if we're in a thread | |
| # If yes, read previous messages in the thread, append to conversation context for AI response | |
| if "thread_ts" in body["event"]: | |
| # Get the messages in the thread | |
| thread_ts = body["event"]["thread_ts"] | |
| messages = app.client.conversations_replies( | |
| channel=body["event"]["channel"], ts=thread_ts | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment