Inspiration

Subscription-based businesses often lose customers due to payment failures, declining engagement, or unexpected churn. Small businesses may not have the tools or resources to identify at-risk customers early and take meaningful action.

We wanted to build an AI-powered retention agent that could help businesses identify customers at risk of leaving, recommend appropriate retention actions, and create payment offers through PayPal.

Our goal was to go beyond a simple machine learning prediction and build a practical, deployable system that connects AI-driven insights with payment workflows.

What it does

ChurnGuard Agent is an intelligent, rule-based customer retention system powered by machine learning and PayPal Sandbox.

  • Churn Risk Prediction: Uses a scikit-learn machine learning model trained on public telecom churn data to estimate customer churn risk.
  • Intelligent Retention Decisions: Applies predefined business rules to select appropriate actions based on churn risk and payment failure counts.
  • PayPal Sandbox Integration: Creates a discounted PayPal sandbox order for a high-risk customer with repeated payment failures.
  • LLM-Powered Explanations: Uses Google Gemini to generate concise, human-readable explanations for retention decisions, with a rule-based fallback.
  • Decision Logging: Records customer risk scores, actions, reasons, and payment order information.
  • Live Dashboard: Provides a hosted dashboard to visualize customer decisions and retention offers.

The system demonstrates how machine learning, AI explanations, business rules, and payment APIs can work together in a customer retention workflow.

How we built it

We built ChurnGuard Agent using Python and a modular backend architecture.

Technology Stack:

  • Python
  • scikit-learn
  • Flask
  • PayPal Sandbox Orders API
  • Google Gemini API
  • HTML/CSS dashboard
  • Gunicorn
  • Render
  • Git and GitHub

Workflow:

  1. Customer data is processed by a trained churn prediction model.
  2. The model generates a churn risk score.
  3. A rule-based agent evaluates the risk score and payment failure information.
  4. The agent selects a retention action.
  5. For the highest-risk demo customer, a discounted PayPal Sandbox order is created.
  6. Google Gemini generates a one-sentence explanation of the decision.
  7. All decisions are logged and displayed on the dashboard.

The application is deployed on Render, and the source code is available on GitHub with setup instructions in the README.

Challenges we ran into

PayPal API Integration: Integrating the PayPal Sandbox Orders API and handling order creation and approval flows required careful testing.

Subscription Workflow Verification: The sandbox subscription did not complete approval, so signed subscription event handling could not be verified end to end.

Invoicing Limitations: The invoicing API returned a 403 error during development. We adapted the implementation to use the PayPal Orders API for the demo offer.

Model Performance: The initial churn model is a prototype with limited precision and recall. We focused on building a functional end-to-end workflow while documenting the model's limitations honestly.

LLM Reliability: We needed to ensure that language model explanations did not control the actual retention decision. We separated the rule-based decision logic from the LLM-generated explanations and implemented a fallback.

Deployment and Reproducibility: Making the application accessible through a hosted dashboard while maintaining a clean, cloneable GitHub repository was another important challenge.

Accomplishments that we're proud of

  • Built a functional AI-powered customer retention agent.
  • Integrated machine learning churn scoring with rule-based business decisions.
  • Successfully created a PayPal Sandbox order from a high-risk model-scored customer.
  • Demonstrated a discounted $8.00 sandbox offer for a customer with a 0.97 churn risk score and two demo payment failures.
  • Integrated Gemini for natural-language decision explanations.
  • Deployed the dashboard publicly on Render.
  • Implemented a health check endpoint for deployment verification.
  • Maintained a clean GitHub repository with documentation and reproducible setup instructions.
  • Clearly documented verified functionality, limitations, and untested workflows.

We are proud that ChurnGuard Agent is not just a trained model or a conceptual prototype, but a deployed application demonstrating a complete retention decision workflow.

What we learned

Through this project, we learned how to connect machine learning predictions with real-world business workflows.

We gained practical experience with:

  • Integrating payment APIs into a Python backend.
  • Designing rule-based AI agent workflows.
  • Separating model predictions, business decisions, and LLM explanations.
  • Handling API errors and incomplete sandbox workflows.
  • Deploying and maintaining a web application.
  • Documenting model performance and system limitations.
  • Building reproducible projects with GitHub and deployment documentation.

Most importantly, we learned that building a reliable AI system requires more than model accuracy. It also requires robust integration, clear decision logic, testing, deployment, and transparency.

What's next for ChurnGuard Agent

Our next steps include:

  • Completing end-to-end PayPal subscription approval and signed webhook event verification.
  • Improving churn prediction performance with better feature engineering, model evaluation, and additional datasets.
  • Replacing demo payment failure values with verified subscription payment data.
  • Exploring automated retention workflows for different customer segments.
  • Adding real-time monitoring, analytics, and improved dashboard functionality.
  • Expanding the system toward a production-ready customer retention platform.

ChurnGuard Agent is currently a prototype built and demonstrated using PayPal Sandbox. Our long-term vision is to help subscription businesses proactively reduce customer churn through intelligent, explainable, and automated retention workflows.

Built With

Share this project:

Updates

Submission history