Normalized for Mintlify from
knowledge-base/aiconnected-apps-and-modules/modules/funnelChat/legacy-funnelChat-readme.mdx.funnelChat by aiConnected
> An AI-powered chatbot platform for debt collection and accounts receivable management📋 Table of Contents
- Overview
- Features
- Architecture
- Tech Stack
- Prerequisites
- Installation
- Configuration
- Development
- Testing
- Deployment
- API Documentation
- Contributing
- License
🎯 Overview
funnelChat is a comprehensive AI chatbot platform designed specifically for the debt collection and accounts receivable industry. It provides automated, compliant, and empathetic communication with debtors across multiple channels while giving businesses powerful tools to manage their collections process.What Does This Platform Do?
For Debtors (Public-Facing):- Receive payment reminders via SMS, WhatsApp, email, and web chat
- Negotiate payment plans through conversational AI
- Make payments securely
- Request payment plan modifications
- Access account information 24/7
- Manage debtor accounts and communication
- Monitor AI chatbot conversations
- Configure automated workflows
- Track payment analytics and recovery rates
- Ensure regulatory compliance (FDCPA, TCPA, CFPB)
- Generate compliance reports
✨ Features
Core Features
1. Multi-Channel Communication
- SMS Chatbot - Text message conversations
- WhatsApp Integration - Global messaging support
- Email Bot - Automated email responses
- Web Widget - Embedded chat on customer portals
- Voice Bot - IVR integration for phone calls
2. AI-Powered Conversations
- Natural language understanding
- Sentiment analysis
- Empathetic response generation
- Multi-language support (English, Spanish)
- Context-aware dialogue management
3. Payment Management
- Secure payment processing via Stripe
- Dynamic payment plan generation
- Automated payment reminders
- Failed payment retry logic
- Settlement offer calculations
4. Compliance & Security
- Real-time FDCPA compliance checking
- Automated audit trails
- Encrypted data storage
- PCI DSS compliant payment handling
- TCPA consent management
5. Analytics & Reporting
- Real-time dashboards
- Recovery rate tracking
- Channel performance metrics
- Debtor engagement analytics
- Compliance reports
🏗️ Architecture
High-Level Architecture
System Components
Front-End Applications
- Debtor Portal - Public-facing chat interface for debtors
- Business Dashboard - Collection agent interface
- Admin Panel - System configuration and management
Back-End Services
- API Gateway - Central request router and authenticator
- Chatbot Service - AI conversation orchestration
- Payment Service - Payment processing and plan management
- Analytics Service - Data aggregation and reporting
- Compliance Service - Regulatory monitoring and enforcement
- Notification Service - Multi-channel message delivery
🛠️ Tech Stack
Front-End
- Framework: React 18+ with TypeScript
- State Management: Redux Toolkit
- UI Components: Material-UI (MUI) v5
- Routing: React Router v6
- Form Management: React Hook Form
- Data Fetching: React Query (TanStack Query)
- Charts: Recharts
- Real-time: Socket.io Client
Back-End
- Runtime: Node.js 20 LTS
- Framework: Express.js 4.18+
- Language: TypeScript 5.0+
- API Documentation: OpenAPI 3.0 (Swagger)
- WebSockets: Socket.io 4.0+
- Job Queue: Bull (Redis-based)
- Validation: Joi / Zod
Database
- Primary Database: PostgreSQL 15+
- ORM: Prisma 5.0+
- Cache: Redis 7.0+
- Search: PostgreSQL Full-Text Search
AI & NLP
- LLM Provider: Anthropic Claude API
- Model: Claude Sonnet 4
- Prompt Management: Custom prompt templates
- Sentiment Analysis: Custom Claude prompts
Third-Party Integrations
- Payments: Stripe API
- SMS/WhatsApp: Twilio API
- Email: SendGrid API
- File Storage: AWS S3 or compatible
- Monitoring: Datadog / New Relic (optional)
Infrastructure
- Containerization: Docker
- Orchestration: Docker Compose (dev), Kubernetes (prod)
- CI/CD: GitHub Actions
- Hosting: AWS / DigitalOcean / Render
- CDN: CloudFlare
Development Tools
- Version Control: Git
- Package Manager: npm or pnpm
- Code Quality: ESLint, Prettier
- Testing: Jest, Supertest, React Testing Library
- API Testing: Postman / Insomnia
📦 Prerequisites
Before you begin, ensure you have the following installed:Required Software
- Node.js: v20.0.0 or higher (Download)
- PostgreSQL: v15 or higher (Download)
- Redis: v7.0 or higher (Download)
- Git: Latest version (Download)
- Docker: Latest version (Download) - Optional but recommended
Required API Keys
You’ll need to sign up and obtain API keys from:- Anthropic - For Claude AI (https://console.anthropic.com/)
- Stripe - For payment processing (https://stripe.com/)
- Twilio - For SMS/WhatsApp (https://www.twilio.com/)
- SendGrid - For email (https://sendgrid.com/)
Development Skills
- JavaScript/TypeScript basics
- Understanding of REST APIs
- Basic SQL knowledge
- Familiarity with Git commands
🚀 Installation
Option 1: Docker Setup (Recommended for Beginners)
- Clone the repository
- Copy environment variables
- Edit the .env file with your API keys
- Start all services with Docker
- Run database migrations
- Seed the database (optional, for test data)
- Access the applications
- Debtor Portal: http://localhost:3000
- Business Dashboard: http://localhost:3001
- Admin Panel: http://localhost:3002
- API: http://localhost:4000
Option 2: Manual Setup
Step 1: Clone Repository
Step 2: Install Dependencies
Install backend dependencies:Step 3: Setup Database
Create PostgreSQL database:Step 4: Configure Environment Variables
Backend (.env):.env file:
Step 5: Run Database Migrations
Step 6: Seed Database (Optional)
- Admin user (admin@funnelchat.com / admin123)
- Sample business accounts
- Sample debtor accounts
- Sample payment plans
Step 7: Start Development Servers
Terminal 1 - Backend API:⚙️ Configuration
Environment Variables Explained
Critical Security Settings
JWT_SECRET- Used to sign authentication tokens. MUST be unique and random (at least 32 characters)STRIPE_WEBHOOK_SECRET- Validates Stripe webhook authenticity- Database passwords should be strong and unique
API Keys
Each service requires an API key:- Anthropic: Get from https://console.anthropic.com/
- Stripe: Get from https://dashboard.stripe.com/apikeys
- Twilio: Get from https://console.twilio.com/
- SendGrid: Get from https://app.sendgrid.com/settings/api_keys
Feature Flags
Toggle features on/off:Database Configuration
The system uses Prisma ORM. Schema is inbackend/prisma/schema.prisma.
Common commands:
Stripe Configuration
1. Create Products in Stripe Dashboard
Navigate to Products and create:- Free Tier - $0.00/month
- Basic Plan - $99.97/month
- Premium Plan - $149.97/month
- Overage Messaging - $0.015 per message (usage-based)
2. Configure Webhooks
Add webhook endpoint:https://your-domain.com/api/webhooks/stripe
Select events:
checkout.session.completedcustomer.subscription.createdcustomer.subscription.updatedcustomer.subscription.deletedinvoice.payment_succeededinvoice.payment_failed
3. Test Mode
During development, use Stripe test mode:- Test card:
4242 4242 4242 4242 - Any future expiry date
- Any 3-digit CVC
Twilio Configuration
1. Purchase Phone Numbers
- Buy a phone number with SMS capability
- Buy a phone number with WhatsApp capability (optional)
2. Configure Webhooks
Set SMS webhook to:https://your-domain.com/api/webhooks/twilio/sms
Set WhatsApp webhook to: https://your-domain.com/api/webhooks/twilio/whatsapp
3. Messaging Service
Create a Messaging Service in Twilio for better deliverability.💻 Development
Project Structure
Coding Standards
TypeScript
- Use strict mode:
"strict": truein tsconfig.json - Avoid
anytype; use proper typing - Use interfaces for object shapes
- Use enums for fixed sets of values
Naming Conventions
- Files: kebab-case (e.g.,
payment-service.ts) - Classes: PascalCase (e.g.,
PaymentService) - Functions: camelCase (e.g.,
calculatePaymentPlan) - Constants: UPPER_SNAKE_CASE (e.g.,
MAX_RETRY_ATTEMPTS) - Components: PascalCase (e.g.,
ChatWidget.tsx)
Code Organization
- One component per file
- Keep functions small (< 50 lines)
- Extract reusable logic into hooks or utils
- Comment complex logic
Git Workflow
feat:- New featurefix:- Bug fixdocs:- Documentationstyle:- Code style changesrefactor:- Code refactoringtest:- Adding testschore:- Maintenance tasks
Development Workflow
1. Start Development Environment
2. Watch for File Changes
Backend and frontend will auto-reload on file changes when usingnpm run dev or npm start.
3. View Logs
4. Access Database
5. Test API Endpoints
Use Postman collection indocs/postman/ or:
Common Development Tasks
Add a New API Endpoint
- Create route in
backend/src/api/routes/:
- Create controller in
backend/src/api/controllers/:
- Register route in
backend/src/api/index.ts:
Add a New React Component
- Create component file:
- Use in parent component:
Add a Database Table
- Update Prisma schema:
- Create migration:
- Apply migration:
🧪 Testing
Running Tests
Run all tests:Test Structure
E2E Testing
E2E tests use Playwright or Cypress:🚢 Deployment
Environment Setup
Create separate environments:- Development - Local machine
- Staging - Pre-production testing
- Production - Live system
Deployment Checklist
Before deploying to production:- All tests passing
- Environment variables configured
- Database migrations applied
- API keys are production keys (not test)
- SSL certificates configured
- Monitoring/logging setup
- Backup strategy in place
- Security review completed
- Compliance audit passed
Docker Deployment
Build production images:Cloud Deployment Options
AWS (Recommended)
- Compute: ECS or EKS for containers
- Database: RDS for PostgreSQL
- Cache: ElastiCache for Redis
- Storage: S3 for files
- CDN: CloudFront
DigitalOcean (Budget-Friendly)
- Compute: App Platform or Droplets
- Database: Managed PostgreSQL
- Cache: Managed Redis
- Storage: Spaces (S3-compatible)
Render (Easiest for Beginners)
- Web Services: Auto-deploy from Git
- Databases: Managed PostgreSQL
- Redis: Managed Redis
- Static Sites: Auto-deploy frontends
Continuous Deployment
GitHub Actions example:Database Migrations in Production
Safe migration process:- Backup database:
- Test migration on staging:
- Deploy to production:
- Verify application:
Monitoring
Set up monitoring for:- Application health: Uptime checks
- API performance: Response times
- Error rates: Exception tracking
- Database performance: Query times
- Message delivery: Channel success rates
- Datadog
- New Relic
- Sentry (error tracking)
- CloudWatch (AWS)
📚 API Documentation
Authentication
All API requests require authentication via JWT token. Get token:Key Endpoints
Full API documentation available at:http://localhost:4000/api-docs (Swagger UI)
Core endpoints:
POST /api/auth/login- User loginPOST /api/auth/register- User registrationGET /api/accounts- List accountsGET /api/accounts/:id- Get account detailsPOST /api/conversations- Start conversationPOST /api/payments- Process paymentGET /api/analytics/dashboard- Get dashboard data
WebSocket Events
Real-time communication uses Socket.io. Client connection:message- New chat messagetyping- User is typingpayment_update- Payment status changeconversation_assigned- Conversation assigned to agent
🤝 Contributing
We welcome contributions! Please follow these guidelines.Getting Started
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Write/update tests
- Commit your changes (
git commit -m 'feat: add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Pull Request Process
- Update documentation if you changed APIs or behavior
- Add tests for new functionality
- Ensure all tests pass:
npm test - Follow code style:
npm run lint - Update CHANGELOG.md with your changes
- Request review from maintainers
Code Review Criteria
- Code follows project conventions
- Adequate test coverage (>80%)
- No security vulnerabilities
- Performance considerations addressed
- Documentation updated
- Commit messages are clear
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.🆘 Support
Getting Help
- Documentation: Check this README and PRD
- Issues: Create GitHub issue with bug/feature tag
- Discussions: Use GitHub Discussions for questions
- Email: support@funnelchat.com
Common Issues
Issue: Cannot connect to databaseTroubleshooting Commands
📞 Contact
- Project Lead: Oxford Pierpont
- Organization: aiConnected
- Website: https://funnelchat.com
- GitHub: https://github.com/your-org/funnelchat
Happy Coding! 🚀