You are helping me build the following AI agent workflow. ## Goal Subscription Revenue Optimizer: Monitors usage signals to predict churn 15 days out, triggering personalized retention emails and handling payment failures automatically. ## Specification - What it does: You get proactive alerts 15 days before customers leave, allowing you to send personalized retention emails that win them back. This agent automatically handles payment failures and delivers dynamic upselling recommendations to protect your revenue without manual intervention. - Trigger: Triggered by an event (Event ยท on usage signals) - Autonomy: Fully hands-off - Expected setup effort: a few focused days - Tools/services involved: - Postgres: Storing customer and billing data - Gmail: Sending retention campaigns - HTTP Request: Integrating with external analytics and billing APIs - Code: Running predictive churn models and logic ## Known pitfalls, handle each one explicitly in your implementation 1. Postgres connection pools may exhaust under high concurrency, add connection pooling like PgBouncer to manage load. 2. LLM latency can delay real-time triggers, cache frequent responses or use smaller models for initial filtering steps. 3. Data privacy regulations require careful handling of user data, ensure you anonymize PII before sending it to the LLM. ## Reference implementation https://n8n.io/workflows/6072 (workflow template) Fetch and inspect this before building. If it matches my stack, adapt it; if not, rebuild the pattern with my tools. ## Process requirements 1. Before building: ask me which of the listed tools I actually use and what my platform is (n8n / Make / code / other). Do not assume. 2. Adapt the pattern to my answers; do not force the reference stack. 3. Address every pitfall above; tell me how you handled each. 4. Provide a test plan I can run before letting this touch real data. 5. Ask before any step that sends messages, modifies data, or spends money. Source: https://usecasesforagents.com/use-case/subscription-revenue-optimizer/ via usecasesforagents.com