From f11aa385009c71ee3e5616bff979737d1d4107a7 Mon Sep 17 00:00:00 2001 From: Mostafa Mohamed Date: Wed, 17 Apr 2024 15:13:39 +0200 Subject: [PATCH] Ref #36 -- Add additional instructions --- sam/slack.py | 8 ++++++++ slack-manifest.yml | 1 + 2 files changed, 9 insertions(+) diff --git a/sam/slack.py b/sam/slack.py index fab87f3..105ea99 100644 --- a/sam/slack.py +++ b/sam/slack.py @@ -33,6 +33,14 @@ def handle_message(event: {str, Any}, say: Say): channel_type = event["channel_type"] user_id = event["user"] text = event["text"] + profile = say.client.users_profile_get(user=user_id) + name = profile["profile"]["display_name"] + email = profile["profile"]["email"] + additional_instructions = f"Always say the user name {name} when replying" + additional_instructions += ( + f"\nIf you are being asked about the email it is: {email}" + ) + text += f"\n{additional_instructions}" text = text.replace(f"<@{USER_HANDLE}>", "Sam") thread_id = utils.get_thread_id(channel_id) # We may only add messages to a thread while the assistant is not running diff --git a/slack-manifest.yml b/slack-manifest.yml index 996c6b4..9569833 100644 --- a/slack-manifest.yml +++ b/slack-manifest.yml @@ -21,6 +21,7 @@ oauth_config: - chat:write - commands - users:read + - users.profile:read - files:read - files:write - reactions:write