A customizable, OpenAI-powered chat widget for Django projects
Project description
Django ChatWidget
Django ChatWidget is a plug-and-play AI-powered chat assistant built for Django. Drop it into your site and let users interact with a personalized chatbot powered by OpenAI, trained on your custom .json knowledge base.
🚀 Features
- Floating chat interface embedded in your site
- Powered by OpenAI’s GPT models (configurable)
- Custom knowledge base: just drop
.jsonfiles inchatwidget/data/ - Fully static frontend with no database dependency
- Easy integration via
{% include "chatwidget/widget.html" %}
🧠 Training the Chatbot
To add your own knowledge:
- Create
.jsonfiles inchatwidget/data/ - Each file must contain either a list or a dictionary with
"title"and"content"fields. - The assistant uses this as system context when replying.
Example:
[
{
"title": "About Matt",
"content": "Matt Raynor is a quadriplegic developer and creator who rebuilt his life through code. View his portfolio at matthewraynor.com."
}
]
The assistant will automatically load all .json files on server start.
🛠 Installation
# Option 1: Clone into your project
git clone https://github.com/mattyray/django-chatwidget.git
Add chatwidget to INSTALLED_APPS in your Django settings:
INSTALLED_APPS = [
...
"chatwidget",
]
Include it in your urls.py:
path("chatwidget/", include("chatwidget.urls")),
Include the widget in your base template:
{% include "chatwidget/widget.html" %}
🔑 OpenAI API Key
Set your key as an environment variable or in your settings:
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
📁 Project Structure
chatwidget/
├── data/ # Your custom chatbot knowledge base
├── static/chatwidget/ # CSS and JS
├── templates/chatwidget/ # Widget HTML
├── views.py
├── urls.py
├── openai_utils.py
📄 License
MIT © 2025 Matthew Raynor
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_chatwidget-0.1.1.tar.gz.
File metadata
- Download URL: django_chatwidget-0.1.1.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10c9041d39e1d063b09fdc313fe9665c654ae37c66239d7add6d94ac61fda62f
|
|
| MD5 |
4e4eb33a06db445723f01515a103d1d2
|
|
| BLAKE2b-256 |
bf4cdfa6d47266ad6b1f412066266c943b5d585bf93c65e8d2470c76c1d49c2b
|
File details
Details for the file django_chatwidget-0.1.1-py3-none-any.whl.
File metadata
- Download URL: django_chatwidget-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1e41f41b50bda9522934dc0656a67edf2a20b9fbb4aac9936ba61bccd71ebe7
|
|
| MD5 |
35375d246f56eebcb76f700071193c1f
|
|
| BLAKE2b-256 |
9ed3982feb10f84c95555bb39dd1d6b67d2970d1ec020375840d758a79db3a38
|