π¬π§ English | π«π· FranΓ§ais
This repository is a technical presentation and documentation repository.
It does not contain downloadable source code or production files.
A complete project to build your own Flask-based conversational assistant, ready to run:
- locally (localhost)
- on shared hosting such as o2switch (Passenger / cPanel)
No external database, no hidden dependencies. You can use it as-is, modify it, or integrate it into another website or API.
This project provides a self-hosted conversational assistant built with Flask,
designed for developers and teams who want full control over their chatbotβs behavior and deployment.
The architecture prioritizes:
- a local knowledge base (JSON) as the primary source
- predictable behavior in professional environments
- optional AI integration (OpenAI)
- simple deployment without dependency on external SaaS platforms
flask_chatbot_advanced_2.0/
β
βββ app.py β Flask entry point (server + API routes)
βββ main.py β Bot logic: responses (OpenAI + local JSON)
βββ storage.py β SQLite-based conversation history (save & read)
β
βββ passenger_wsgi.py β For hosting on o2switch / Passenger
βββ requirements.txt β Python dependencies (Flask, CORS, SQLite, OpenAI...)
βββ .env.example β Template for the user (βfill in your API key hereβ)
β # β The .env file is NOT included (user must create it to use OpenAI)
β # β The data.db file is not provided (created automatically on first run)
β
βββ Dockerfile β Dockerfile β (optional) Docker container
βββ docker-compose.yml β docker-compose.yml β (optional) Simplified Docker launch
β
βββ LICENSE.md β Terms of use and legal framework
β
βββ install.bat β Windows installation script (pip install + launch)
βββ install.sh β Linux/Mac script (chmod + pip install)
β
βββ sample_data/
β βββ sample_data.json β Local content database (FAQ, simple answers)
β
βββ templates/
β βββ index.html β User interface (chatbot frontend)
β βββ widget.html β New floating interface
β
βββ static/
β βββ widget.js β Script to open/close the floating widget
β βββ widget.css β Style for the floating widget (button + mini-window)
β
βββ logs/
β βββ errors.log β Automatically created on error
β
βββ docs/
βββ README_TECHNIQUE.md β Technical documentation and internal architecture
βββ README.md β Main project documentation and guides
βββ CUSTOMISATION.md β Bot customization (design, responses, OpenAIβ¦)
βββ INSTALL.md β Complete user guide
- Compatible with o2switch / Passenger (shared hosting)
- No database required (JSON-based operation)
- Readable, well-commented and easily customizable code
- CORS enabled: usable with websites or frontend interfaces
- Integrated logging system: errors automatically recorded in
/logs/
This chatbot is designed for:
- internal knowledge assistants
- support or documentation automation
- self-hosted AI assistants
- internal tools requiring controlled responses
- websites embedding a chatbot widget
The system can operate fully offline using a local knowledge base,
or optionally use OpenAI when extended responses are required.
When the chatbot is launched for the first time, some files are created automatically:
| File | Purpose |
|---|---|
data.db |
SQLite database storing conversations (if ENABLE_PERSISTENCE=true) |
logs/errors.log |
Created only when a server error occurs |
.env |
Must be created from .env.example to enable OpenAI |
| Mode | Description | Requires OpenAI Key |
|---|---|---|
| Local JSON (default) | Responses generated from the local knowledge base | No |
| OpenAI GPT (optional) | Uses OpenAI API when a key is provided | Yes |
The mode is automatically selected depending on the presence of the OPENAI_API_KEY variable in .env.
No tokens are consumed if no key is provided.
The logs/ directory automatically records Flask server errors:
- automatic creation of
logs/errors.logwhen an error occurs - automatic creation of the
logs/directory if missing - recording of date, error message and full traceback
This system works:
- in local mode
- with or without OpenAI
- in production (Passenger / shared hosting)
Palks Studio β Version 2.0 (Advanced Edition)
Compatible with Python 3.12+ and Flask 3.0+
Β© Palks Studio β see LICENSE.md
