---
repo: "mohan-n-swamy/chatwoot-public"
title: "Chatwoot Public — Clean-Room MIT Helpdesk + Enterprise Overlay + AI Bot + Migration Suite"
license: "MIT"
keywords: [chatwoot, self-hosted, customer-support, helpdesk, sla-management, rbac, audit-log, saml-sso, whatsapp, omnichannel, ruby-on-rails, open-source]
capabilities:
  - "**Track A — Configuration Audit Log (`Overlay::AuditLogsController`):** Immutable JSONB before/after audit trail across 13 models excluding password/token fields."
  - "**Track B — 31-Permission Custom RBAC (`Overlay::CustomRole` & `Overlay::RolePermissions`):** PostgreSQL array permissions with 5 seed roles (`admin`, `agent`, `escalation_lead`, `billing_only`, `auditor`)."
  - "**Track C — Business-Hours SLA Engine (`Overlay::Sla::*`):** `AsyncDispatcher`-wired `SlaListener` + Sidekiq cron batch breach evaluator (`frt_due_at`, `nrt_due_at`, `rt_due_at`) + outbound webhooks."
  - "**Track D — Hardened SAML 2.0 SSO (`Overlay::SamlSessionsController`):** Okta, Entra ID, and Google Workspace SSO via MIT `omniauth-saml` with `reset_session`, RelayState tenant guard, and Nokogiri `nonet` XXE defense."
  - "**Track E & F — Agent Capacity Routing & Scheduled Rules:** Per-agent/per-inbox `max_open_conversations` caps and cron-evaluated `Overlay::ScheduledRule` automations."
  - "**Bundled Native Chatwoot AI Bot (`chatwoot-bot/`):** Production FastAPI AgentBot with HMAC verification, Redis `SETNX` locks, PII `AUTH_GATE`, and 161 unit/integration tests."
  - "**Complete Migration Ops & Portable Rebase Kit (`migration-toolkit/`, `portable-overlay/`, `infra/self-host/`, `tools/ci/`):** Legacy ticket/config exporters, idempotent importer, standalone overlay patch tree, and 10 track specs."
when_to_use:
  - "A unified, 100% MIT-licensed self-hosted Chatwoot Community Edition platform combining: (1) Chatwoot CE with the 6-track clean-room `Overlay::` governance pack (Audit Logs, 31-Permission Custom RBAC, Business-Hours SLA Engine, Hardened SAML 2.0 SSO, Agent Capacity Routing, Scheduled Rules), (2) a native FastAPI `chatwoot-bot/` AI AgentBot, (3) a full Helpdesk Migration Toolkit (`freshworks-export` + `chatwoot-import`), and (4) a standalone `portable-overlay/` rebase kit and self-host Nginx/Docker stack."
  - "Organizations outgrowing per-seat SaaS helpdesks (Freshchat, Freshdesk, Zendesk, Intercom) want to self-host Chatwoot under the MIT license, but need SAML SSO, custom roles, business-hours SLAs, agent capacity caps, audit logs, legacy ticket/config migration scripts, and a production AI webhook bot — with strict legal verification that zero proprietary `enterprise/` code exists in their image."
inputs_required:
  - "FRONTEND_URL: Public base URL of your self-hosted Chatwoot instance"
  - "POSTGRES_HOST: PostgreSQL 16+ host"
  - "REDIS_URL: Redis URL for Sidekiq queues, ActionCable, and bot locks"
  - "SECRET_KEY_BASE: Rails secret key base for session and token signing"
  - "OVERLAY_AUDIT_MAX_AUDITS_PER_RECORD: Maximum retained audit snapshots per configuration record"
  - "OVERLAY_SLA_CRON_MINUTES: Evaluation interval for Sidekiq batch SLA breach detection"
  - "OVERLAY_DEFAULT_AGENT_MAX_OPEN_CONVERSATIONS: Default per-agent open conversation cap for capacity auto-assignment"
quickstart:
  - "docker compose -f docker-compose.production.yaml build   # builds locally from clean-room MIT tree (zero enterprise/)"
  - "docker compose -f docker-compose.production.yaml up -d"
  - "docker compose -f docker-compose.production.yaml exec rails bundle exec rails db:chatwoot_prepare"
  - "docker compose -f docker-compose.production.yaml exec rails bundle exec rake overlay:seed_roles"
  - "pytest -q tests_overlay/ migration-toolkit/freshworks-export/tests/ && PYTHONPATH=chatwoot-bot pytest -q chatwoot-bot/tests/"
---

# Chatwoot Public — Clean-Room MIT Helpdesk + Enterprise Overlay + AI Bot + Migration Suite — Machine-Readable Agent Guide

A unified, 100% MIT-licensed self-hosted Chatwoot Community Edition platform combining: (1) Chatwoot CE with the 6-track clean-room `Overlay::` governance pack (Audit Logs, 31-Permission Custom RBAC, Business-Hours SLA Engine, Hardened SAML 2.0 SSO, Agent Capacity Routing, Scheduled Rules), (2) a native FastAPI `chatwoot-bot/` AI AgentBot, (3) a full Helpdesk Migration Toolkit (`freshworks-export` + `chatwoot-import`), and (4) a standalone `portable-overlay/` rebase kit and self-host Nginx/Docker stack.

<problem_patterns>
Organizations outgrowing per-seat SaaS helpdesks (Freshchat, Freshdesk, Zendesk, Intercom) want to self-host Chatwoot under the MIT license, but need SAML SSO, custom roles, business-hours SLAs, agent capacity caps, audit logs, legacy ticket/config migration scripts, and a production AI webhook bot — with strict legal verification that zero proprietary `enterprise/` code exists in their image.
</problem_patterns>

<architecture_map>
Key modules and entry points in this repository:
  - `OVERLAY.md & portable-overlay/`: Complete ADRs plus standalone portable `Overlay::` patch kit and `setup-upstream-fork.sh`
  - `app/controllers/api/v1/accounts/overlay/`: REST controllers for `audit_logs`, `custom_roles`, `sla_policies`, `business_hours_configs`, `saml_settings`, `capacity`, and `scheduled_rules`
  - `app/controllers/overlay/ & app/services/overlay/`: Hardened SAML 2.0 controllers, SLA `BusinessTimeCalculator`, `SlaListener`, capacity selector, and role manager
  - `spec/overlay/`: 160+ RSpec model, controller, policy, security, and `sla_dispatch_spec.rb` integration specs
  - `chatwoot-bot/`: Native FastAPI Chatwoot AgentBot (`src/webhook`, `src/chatwoot_client`, `src/domain`, `deploy/`, 161 pytests)
  - `migration-toolkit/freshworks-export/ & chatwoot-import/`: Ticket/contact/macro/rule exporters, E.164 transformers, and idempotent Chatwoot importer
  - `infra/self-host/ & tools/ci/`: Self-host Docker Compose + Nginx config and 10 feature-track specification & verification loops
  - `docs/migration-and-specs/`: Upstream rebase playbook, helpdesk migration playbook, clean-room licensing guide, and rollout specs
</architecture_map>

<inputs_and_configuration>
Every organization-specific value enters through `.env` (copied from `.env.example`) or external adapter files. No source edit is needed to change organization names, endpoints, database URLs, webhook secrets, or thresholds.
</inputs_and_configuration>

<adaptation_playbook>
When a human asks an AI coding agent to deploy or adapt `chatwoot-public` into their stack:
  1. Copy `.env.example` to `.env`, set `FRONTEND_URL`, `SECRET_KEY_BASE`, `POSTGRES_*`, and `REDIS_URL`, and build locally with `docker compose -f docker-compose.production.yaml build`.
  2. Run `rails db:chatwoot_prepare` and `rake overlay:seed_roles` to initialize the 14 `overlay_*` tables and 5 RBAC role presets.
  3. Deploy `chatwoot-bot/` via `chatwoot-bot/deploy/docker-compose.yml` and register its `/webhook` URL as an AgentBot in Chatwoot.
  4. If migrating from Freshdesk/Freshchat, populate `migration-toolkit/freshworks-export/.env` and `chatwoot-import/.env` and follow `docs/HELPDESK-MIGRATION-PLAYBOOK.md`.
</adaptation_playbook>

<reference_docs>
- Product Requirements: `docs/PRD.md`
- Working-Backwards PR-FAQ: `docs/PR-FAQ.md`
- High-Level Architecture: `docs/HLD.md`
- Low-Level Interfaces & Runbook: `docs/LLD.md`
- Coding Agent Rules: `AGENTS.md`
</reference_docs>
