Making Notifications Useful
Welcome to Day 19. Today involves a simple but powerful Python tweak.
The Goal
Change the email subject line dynamically based on the data content.
The Code Snippet
Inside the lambda_handler:
Python
Sum the amounts
total = sum(float(t['amount']) for t in transactions)
limit = 100.0
Conditional Subject
if total > limit: subject = f"🚨 HIGH SPENDING: {total}€" else: subject = f"✅ Daily Report: {total}€"
Publish to SNS
sns.publish( TopicArn=TOPIC_ARN, Message=ai_generated_text, Subject=subject # <--- Dynamic! )
Now my inbox tells me the story before I even open the email.


Top comments (0)