DEV Community

Cover image for Day 58: Fix your Fintech app's calendar logic (The Payroll Offset)
Eric Rodríguez
Eric Rodríguez

Posted on

Day 58: Fix your Fintech app's calendar logic (The Payroll Offset)

When building AI-powered apps, your standard notification logic needs a serious rethink.

Today, I wanted my AI Financial Agent to send a daily morning email to all users by default.

The Problem: Traditional B2C apps send static templates (cheap). My app uses Amazon Bedrock to generate custom semantic text (expensive). If I blindly loop through 500 inactive or test users and call Bedrock 500 times just to send emails they will never read, my AWS bill will explode. 💥

The Fix: I added a "FinOps" guardrail in my EventBridge Orchestrator Lambda before it pushes tasks to the SQS worker queue.

Python

Before sending to SQS for AI processing, filter out the noise.

valid_users = []
for u in user_metadata_list:
# 1. Product Decision: Opt-out approach
wants_email = u.get('wants_daily_email', True)

# 2. FinOps Decision: Drop ghost/test accounts
is_test_account = str(u.get('user_id', '')).startswith('test_')

if wants_email and not is_test_account:
valid_users.append(u)

Enter fullscreen mode Exit fullscreen mode




ONLY push valid, engaged users to the expensive AI Worker queue

for user in valid_users:
sqs.send_message(QueueUrl=SQS_URL, MessageBody=json.dumps({"user_id": user['user_id']}))
By filtering test_ accounts and respecting user Opt-Outs at the router level, my AI Worker Lambda only invokes the LLM for users that actually matter.

Code for engagement, but architect for cost!

Top comments (0)