Skip to main content
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

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
For Businesses (Back-End):
  • 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

  1. Debtor Portal - Public-facing chat interface for debtors
  2. Business Dashboard - Collection agent interface
  3. Admin Panel - System configuration and management

Back-End Services

  1. API Gateway - Central request router and authenticator
  2. Chatbot Service - AI conversation orchestration
  3. Payment Service - Payment processing and plan management
  4. Analytics Service - Data aggregation and reporting
  5. Compliance Service - Regulatory monitoring and enforcement
  6. 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:
  1. Anthropic - For Claude AI (https://console.anthropic.com/)
  2. Stripe - For payment processing (https://stripe.com/)
  3. Twilio - For SMS/WhatsApp (https://www.twilio.com/)
  4. SendGrid - For email (https://sendgrid.com/)

Development Skills

  • JavaScript/TypeScript basics
  • Understanding of REST APIs
  • Basic SQL knowledge
  • Familiarity with Git commands

🚀 Installation

  1. Clone the repository
  1. Copy environment variables
  1. Edit the .env file with your API keys
  1. Start all services with Docker
  1. Run database migrations
  1. Seed the database (optional, for test data)
  1. Access the applications

Option 2: Manual Setup

Step 1: Clone Repository

Step 2: Install Dependencies

Install backend dependencies:
Install frontend dependencies:

Step 3: Setup Database

Create PostgreSQL database:
Create Redis database:

Step 4: Configure Environment Variables

Backend (.env):
Edit the .env file:
Frontend applications (.env): For each frontend app (debtor-portal, business-dashboard, admin-panel):
Edit:

Step 5: Run Database Migrations

This will create all necessary database tables.

Step 6: Seed Database (Optional)

This creates test data including:
  • Admin user (admin@funnelchat.com / admin123)
  • Sample business accounts
  • Sample debtor accounts
  • Sample payment plans

Step 7: Start Development Servers

Terminal 1 - Backend API:
Terminal 2 - Debtor Portal:
Terminal 3 - Business Dashboard:
Terminal 4 - Admin Panel:
Terminal 5 - Background Jobs (optional):

⚙️ 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:

Feature Flags

Toggle features on/off:

Database Configuration

The system uses Prisma ORM. Schema is in backend/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.completed
  • customer.subscription.created
  • customer.subscription.updated
  • customer.subscription.deleted
  • invoice.payment_succeeded
  • invoice.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": true in tsconfig.json
  • Avoid any type; use proper typing
  • Use interfaces for object shapes
  • Use enums for fixed sets of values
Example:

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

Commit message format:
  • feat: - New feature
  • fix: - Bug fix
  • docs: - Documentation
  • style: - Code style changes
  • refactor: - Code refactoring
  • test: - Adding tests
  • chore: - Maintenance tasks

Development Workflow

1. Start Development Environment

2. Watch for File Changes

Backend and frontend will auto-reload on file changes when using npm run dev or npm start.

3. View Logs

4. Access Database

5. Test API Endpoints

Use Postman collection in docs/postman/ or:

Common Development Tasks

Add a New API Endpoint

  1. Create route in backend/src/api/routes/:
  1. Create controller in backend/src/api/controllers/:
  1. Register route in backend/src/api/index.ts:

Add a New React Component

  1. Create component file:
  1. Use in parent component:

Add a Database Table

  1. Update Prisma schema:
  1. Create migration:
  1. Apply migration:

🧪 Testing

Running Tests

Run all tests:
Run specific test suite:
Run with coverage:
Watch mode (re-runs on file changes):

Test Structure

E2E Testing

E2E tests use Playwright or Cypress:
Example E2E test:

🚢 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:
Push to registry:

Cloud Deployment Options

  • 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:
  1. Backup database:
  1. Test migration on staging:
  1. Deploy to production:
  1. 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
Tools:
  • Datadog
  • New Relic
  • Sentry (error tracking)
  • CloudWatch (AWS)

📚 API Documentation

Authentication

All API requests require authentication via JWT token. Get token:
Use token:

Key Endpoints

Full API documentation available at: http://localhost:4000/api-docs (Swagger UI) Core endpoints:
  • POST /api/auth/login - User login
  • POST /api/auth/register - User registration
  • GET /api/accounts - List accounts
  • GET /api/accounts/:id - Get account details
  • POST /api/conversations - Start conversation
  • POST /api/payments - Process payment
  • GET /api/analytics/dashboard - Get dashboard data

WebSocket Events

Real-time communication uses Socket.io. Client connection:
Events:
  • message - New chat message
  • typing - User is typing
  • payment_update - Payment status change
  • conversation_assigned - Conversation assigned to agent

🤝 Contributing

We welcome contributions! Please follow these guidelines.

Getting Started

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Write/update tests
  5. Commit your changes (git commit -m 'feat: add amazing feature')
  6. Push to the branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

Pull Request Process

  1. Update documentation if you changed APIs or behavior
  2. Add tests for new functionality
  3. Ensure all tests pass: npm test
  4. Follow code style: npm run lint
  5. Update CHANGELOG.md with your changes
  6. 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 database
Issue: API returns 401 Unauthorized
Issue: Chatbot not responding

Troubleshooting Commands

📞 Contact


Happy Coding! 🚀