Plug-and-play AI chatbot platform for local and small businesses.
ChatForge is a lightweight, embeddable chatbot powered by LangChain and any OpenAI-compatible API. Drop it onto any website in minutes — no complex setup, no vendor lock-in.
Getting Started · Configuration · API Reference · Providers · Roadmap
ChatForge gives any business a production-ready AI chatbot with a single line of HTML. It handles conversation memory, streaming responses, session isolation, and graceful fallback — all configurable through a single .env file.
Try ChatForge here:
👉 https://chatforge-lxry.onrender.com
| Feature | Description |
|---|---|
| AI Chat | Works with any OpenAI-compatible API — Groq, OpenAI, Together AI, Ollama, and more |
| Streaming Responses | Real-time token streaming for an instant, ChatGPT-style experience |
| Conversation Memory | Retains full context within each visitor session |
| Quick Reply Buttons | Configurable shortcut buttons for your most common customer questions |
| Smart Fallback | Rule-based NLP engine activates automatically when no API key is configured |
| Rate Limiting | Per-session request throttling to protect API usage and control costs |
| Session Isolation | Each visitor receives a unique session ID — no memory bleed between users |
| Brand Customization | Configure widget color, greeting message, and style to match your business |
| Embeddable Widget | A single <script> tag — works on any website or platform |
| Privacy First | Business owners supply their own API keys — ChatForge stores no data |
| Layer | Technology | Purpose |
|---|---|---|
| Backend | FastAPI + Uvicorn | High-performance async API server |
| AI Layer | LangChain + LangGraph + ChatOpenAI | Unified interface for any OpenAI-compatible LLM |
| Streaming | StreamingResponse + astream() |
Real-time token delivery |
| Memory | MemorySaver |
In-session conversation context |
| Rate Limiting | SlowAPI | Per-session abuse prevention |
| Fallback | Rule-based NLP engine | Always-on responses without an API key |
| Widget | Vanilla JavaScript | Zero-dependency embeddable chat UI |
| Config | .env + python-dotenv |
Single-file business configuration |
git clone https://github.com/AshminDhungana/ChatForge.git
cd ChatForgeRequires Python 3.10 or higher.
pip install -r requirements.txtcp .env.example .envEdit .env with your business details — see Configuration below.
uvicorn backend.main:app --reloadThe server runs at http://localhost:8000. Interactive API docs are available at http://localhost:8000/docs.
Add this single line to any page's HTML:
<script
src="http://localhost:8000/widget.js"
data-project-id="Ashmin-Office"
data-widget-key="your-random-secret"
></script>The widget loads automatically — no additional setup required.
Copy .env.example to .env and fill in your details:
| Variable | Required | Description |
|---|---|---|
BUSINESS_NAME |
Yes | Your business name, used in chatbot responses |
BUSINESS_DESCRIPTION |
Yes | Short description of what your business does |
BUSINESS_HOURS |
Yes | Opening hours, e.g. Mon–Sat 9AM–10PM, Sun 11AM–9PM |
BUSINESS_PHONE |
Yes | Contact phone number |
BUSINESS_ADDRESS |
Yes | Physical address |
BUSINESS_WEBSITE |
Yes | Your website URL |
PROJECT_ID |
Yes | Unique identifier for this chatbot instance, e.g. ashmin-office |
ALLOWED_DOMAINS |
Yes | Comma-separated list of domains allowed to embed the widget |
WIDGET_API_KEY |
No | Secret key for widget authentication — recommended for production |
QUICK_REPLIES |
No | Comma-separated shortcut button labels shown at chat start |
API_KEY |
No | Your LLM provider API key — leave blank to use the fallback engine |
API_BASE |
No | Base URL of your LLM provider — see Supported AI Providers |
MODEL |
No | Model name to use, e.g. llama-3.1-8b-instant |
WIDGET_COLOR |
No | Hex color for the chat widget, e.g. #2563EB |
GREETING_MESSAGE |
No | First message shown to visitors when the widget opens |
RATE_LIMIT |
No | Max requests per session per minute, e.g. 20/minute (default: 20/minute) |
ChatForge supports lightweight widget authentication without requiring a database.
Configure the following variables:
PROJECT_ID="ashmin-office"
ALLOWED_DOMAINS="ashmindhungana.com,www.dhungana_ashmin.com"
WIDGET_API_KEY="your-random-secret"The backend validates:
- Project ID
- Widget API key (if configured)
- Origin header
- Referer header
- Allowed domains
WIDGET_API_KEY is optional but strongly recommended for production. Requests from unauthorized websites are automatically rejected.
POST /api/v1/chatRequest body:
{
"message": "What are your opening hours?",
"session_id": "uuid-per-visitor",
"project_id": "ashmin-office",
"widget_key": "your-random-secret"
}Response:
{
"reply": "We are open Mon–Sat 9AM–10PM, Sun 11AM–9PM.",
"mode": "ai"
}POST /api/v1/chat/streamReturns a text/event-stream. Tokens are streamed in real time to the widget.
| Mode | Trigger | Description |
|---|---|---|
ai |
API key configured | Full LangChain + LLM response with memory |
fallback |
No API key | Rule-based NLP keyword matching |
Any OpenAI-compatible API works out of the box. Set API_BASE in your .env:
| Provider | API Base URL | Cost | Speed |
|---|---|---|---|
| OpenAI | https://api.openai.com/v1 |
Paid | ⚡⚡⚡ |
| Groq | https://api.groq.com/openai/v1 |
Free tier | ⚡⚡⚡⚡ |
| Together AI | https://api.together.xyz/v1 |
Free tier | ⚡⚡⚡ |
| OpenRouter | https://openrouter.ai/api/v1 |
Pay per use | ⚡⚡⚡ |
| Ollama | http://localhost:11434/v1 |
Free (local) | ⚡⚡ |
Recommended for small businesses: Groq — free, extremely fast, and no credit card required to start.
Tokens are sent to the widget in real time using LangChain's astream() and FastAPI's StreamingResponse, rather than waiting for the full reply to complete. The result feels instant.
Each visitor session gets its own LangGraph MemorySaver instance. The bot remembers earlier messages within the same chat. Memory is scoped to the session and cleared when the visitor leaves.
The widget generates a unique UUID per visitor on load. Two visitors chatting simultaneously never share or mix conversation history.
Configurable shortcut buttons appear at the start of the chat. Visitors can tap them instead of typing — useful for common questions like hours, location, and contact info.
Each session is limited to a configurable number of requests per minute (default: 20/minute) via slowapi. This prevents abuse and protects API usage costs. Adjust with the RATE_LIMIT variable in .env.
When no API key is set, ChatForge silently switches to a lightweight rule-based engine:
Visitor sends a message
↓
No API key detected
↓
Keyword matching runs
↓
FAQ-style answer returned
↓
No match → shows business contact info
The chatbot is always online, even with no AI configuration.
- Python 3.10 or higher
- An OpenAI-compatible API key (optional — the fallback engine works without one)
- For Ollama: a locally running Ollama instance at
http://localhost:11434
Install all Python dependencies:
pip install -r requirements.txtNew to ChatForge? Check out the User Guide for a detailed walkthrough for setting it up for your business.
Contributions are welcome.
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature - Commit your changes:
git commit -m 'Add your feature' - Push to the branch:
git push origin feature/your-feature - Open a pull request
For significant changes, please open an issue first to discuss what you'd like to change.
Released under the MIT License.
Having trouble? Open an issue on GitHub.
Made with care for local businesses everywhere.