New to Kestra?
Use blueprints to kickstart your first workflows.
Queries inactive CRM accounts, evaluates churn probability using Anthropic Claude, and dispatches high-urgency retention alerts to Slack.
Customer churn is one of the most critical threats to recurring-revenue software companies. When customer telemetry signals decline, such as daily active logins dropping off, support ticket backlogs lingering, or core feature usage stalling, traditional heuristics often flag accounts only after cancellation notices are submitted.
By orchestrating database telemetry queries alongside Anthropic Claude, revenue teams can synthesize multidimensional product signals into nuanced churn risk assessments with tailored retention playbooks.
This blueprint automates weekly customer retention audits: it pulls inactive accounts from PostgreSQL, prompts Claude to compute an objective churn risk score (0-100) and draft account-specific outreach recommendations, and routes high-priority churn alerts to Customer Success teams via Slack.
weekly_churn_scan trigger (io.kestra.plugin.core.trigger.Schedule) executes every Monday at 09:00 UTC.query_inactive_accounts task (io.kestra.plugin.jdbc.postgresql.Query) pulls top-MRR customer accounts with inactivity exceeding inactive_days_threshold.analyze_churn_risk_with_claude task (io.kestra.plugin.anthropic.ChatCompletion) sends account telemetry to Claude to score churn drivers and formulate retention actions.parse_churn_scores task (io.kestra.plugin.scripts.python.Script) extracts accounts exceeding churn_risk_score_alert_threshold and compiles churn_analysis_report.json.evaluate_high_risk_condition flowable task (io.kestra.plugin.core.flow.If) branches based on whether any high-risk accounts were discovered.alert_customer_success_high_churn (io.kestra.plugin.slack.notifications.SlackIncomingWebhook) delivers an actionable retention card.export_churn_manifest task records execution state for revenue operations dashboards.flowchart TD
A[Schedule: Weekly Monday 09:00 UTC] --> B[query_inactive_accounts: PostgreSQL]
B --> C[analyze_churn_risk_with_claude: Anthropic Claude]
C --> D[parse_churn_scores: Python Score Parser]
D --> E{High Churn Risk Detected?}
E -- Yes --> F[alert_customer_success_high_churn: Slack]
E -- No --> G[log_churn_status_healthy: Log]
F --> H[export_churn_manifest: Return JSON]
G --> H
Building custom retention models requires setting up ETL jobs, embedding inference APIs, and maintaining notification channels. Kestra combines database querying, Anthropic LLM inference, Python parsing, and Slack alerting into a clean, maintainable workflow.
| Name | Type | Default | Description |
|---|---|---|---|
postgres_url |
STRING | jdbc:postgresql://... |
JDBC URL of CRM database. |
postgres_username |
STRING | crm_reader |
Read-only database user. |
inactive_days_threshold |
INT | 30 |
Inactivity window before evaluation. |
churn_risk_score_alert_threshold |
INT | 75 |
Minimum risk score to trigger alert. |
slack_channel |
STRING | #customer-success |
Slack channel destination for alerts. |
{{ outputs.parse_churn_scores.vars.high_risk_detected }}: Boolean flag indicating if high-risk accounts exist.{{ outputs.parse_churn_scores.vars.top_risk_company }}: Company name of top at-risk account.{{ outputs.parse_churn_scores.vars.top_risk_score }}: Numerical churn score of top offender.{{ outputs.parse_churn_scores.outputFiles['churn_analysis_report.json'] }}: Complete JSON diagnostic report.POSTGRES_PASSWORD: Password for the PostgreSQL database user.ANTHROPIC_API_KEY: API key for Anthropic Claude inference.SLACK_WEBHOOK_URL: Slack Incoming Webhook endpoint URL.POSTGRES_PASSWORD, ANTHROPIC_API_KEY, and SLACK_WEBHOOK_URL in your Kestra namespace secrets.LIMIT 10) to keep token usage within API rate limits.last_active_date is indexed to prevent full-table scans during the query step.io.kestra.plugin.hubspot.DealUpdate to automatically create high-urgency renewal risk tasks in your CRM.io.kestra.plugin.core.http.Request to enrich telemetry prior to LLM scoring.io.kestra.plugin.notifications.mail.MailSend.