Skip to content

Instantly share code, notes, and snippets.

@KyMidd
Created July 9, 2025 02:21
Show Gist options
  • Select an option

  • Save KyMidd/0e7b25349cbcca0f85d3eae1befc81a7 to your computer and use it in GitHub Desktop.

Select an option

Save KyMidd/0e7b25349cbcca0f85d3eae1befc81a7 to your computer and use it in GitHub Desktop.
def handle_teams_event(body, event):
# Identify event_type
event_type = body.get("type", "")
# Only process events we care about
if event_type == 'message':
print("🟢 Event type:", event_type)
# Read table names from environment variables
conversation_table_arn = os.environ.get("CONVERSATION_TABLE_ARN")
token_table_arn = os.environ.get("TOKEN_TABLE_ARN")
# Check for existing valid token
dynamodb_client = boto3.client("dynamodb")
# Get AAD ID from event
aadObjectId = body.get("from", {}).get("aadObjectId", "")
if not aadObjectId:
print("🚫 No AAD ID found in event, exiting")
return
# Check if existing token. If not, send user card to send to authentication
# Token is base64 encoded and also encrypted with a CMK key
encrypted_token = get_token(dynamodb_client, aadObjectId, token_table_arn)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment