kolossus-chat-django 1.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. kolossus_chat_django-1.3.0/LICENSE +28 -0
  2. kolossus_chat_django-1.3.0/MANIFEST.in +6 -0
  3. kolossus_chat_django-1.3.0/PKG-INFO +234 -0
  4. kolossus_chat_django-1.3.0/README.md +206 -0
  5. kolossus_chat_django-1.3.0/kolossus_chat/__init__.py +3 -0
  6. kolossus_chat_django-1.3.0/kolossus_chat/__main__.py +6 -0
  7. kolossus_chat_django-1.3.0/kolossus_chat/apps.py +10 -0
  8. kolossus_chat_django-1.3.0/kolossus_chat/checks.py +20 -0
  9. kolossus_chat_django-1.3.0/kolossus_chat/conf.py +256 -0
  10. kolossus_chat_django-1.3.0/kolossus_chat/middleware.py +111 -0
  11. kolossus_chat_django-1.3.0/kolossus_chat/setup_cli.py +351 -0
  12. kolossus_chat_django-1.3.0/kolossus_chat/templates/kolossus_chat/button.html +1 -0
  13. kolossus_chat_django-1.3.0/kolossus_chat/templates/kolossus_chat/marker.html +1 -0
  14. kolossus_chat_django-1.3.0/kolossus_chat/templates/kolossus_chat/script.html +1 -0
  15. kolossus_chat_django-1.3.0/kolossus_chat/templatetags/__init__.py +0 -0
  16. kolossus_chat_django-1.3.0/kolossus_chat/templatetags/kolossus_chat.py +133 -0
  17. kolossus_chat_django-1.3.0/kolossus_chat_django.egg-info/PKG-INFO +234 -0
  18. kolossus_chat_django-1.3.0/kolossus_chat_django.egg-info/SOURCES.txt +27 -0
  19. kolossus_chat_django-1.3.0/kolossus_chat_django.egg-info/dependency_links.txt +1 -0
  20. kolossus_chat_django-1.3.0/kolossus_chat_django.egg-info/entry_points.txt +2 -0
  21. kolossus_chat_django-1.3.0/kolossus_chat_django.egg-info/requires.txt +1 -0
  22. kolossus_chat_django-1.3.0/kolossus_chat_django.egg-info/top_level.txt +1 -0
  23. kolossus_chat_django-1.3.0/pyproject.toml +48 -0
  24. kolossus_chat_django-1.3.0/runtests.py +24 -0
  25. kolossus_chat_django-1.3.0/setup.cfg +4 -0
  26. kolossus_chat_django-1.3.0/tests/__init__.py +0 -0
  27. kolossus_chat_django-1.3.0/tests/settings.py +24 -0
  28. kolossus_chat_django-1.3.0/tests/test_kolossus_chat.py +782 -0
  29. kolossus_chat_django-1.3.0/tests/urls.py +25 -0
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2026, Kolossus AI
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,6 @@
1
+ include README.md LICENSE runtests.py
2
+ recursive-include kolossus_chat/templates *.html
3
+ # Present only in copies downloaded from the Kolossus dashboard.
4
+ include kolossus_chat/kolossus-config.json
5
+ recursive-include tests *.py
6
+ global-exclude __pycache__ *.py[cod]
@@ -0,0 +1,234 @@
1
+ Metadata-Version: 2.4
2
+ Name: kolossus-chat-django
3
+ Version: 1.3.0
4
+ Summary: Add a KolossusAI chat assistant to your Django site with one command.
5
+ Author: Kolossus AI
6
+ License-Expression: BSD-3-Clause
7
+ Project-URL: Homepage, https://kolossus.ai
8
+ Keywords: django,chatbot,ai,chat,assistant,kolossus
9
+ Classifier: Development Status :: 5 - Production/Stable
10
+ Classifier: Environment :: Web Environment
11
+ Classifier: Framework :: Django
12
+ Classifier: Framework :: Django :: 4.2
13
+ Classifier: Framework :: Django :: 5.0
14
+ Classifier: Framework :: Django :: 5.1
15
+ Classifier: Framework :: Django :: 5.2
16
+ Classifier: Framework :: Django :: 6.0
17
+ Classifier: Framework :: Django :: 6.1
18
+ Classifier: Intended Audience :: Developers
19
+ Classifier: Operating System :: OS Independent
20
+ Classifier: Programming Language :: Python :: 3
21
+ Classifier: Programming Language :: Python :: 3 :: Only
22
+ Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
23
+ Requires-Python: >=3.9
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: Django>=4.2
27
+ Dynamic: license-file
28
+
29
+ # KolossusAI Chat for Django
30
+
31
+ Add a Kolossus AI assistant to your Django site, as a chat bubble on every page or as
32
+ a button wherever you place a template tag.
33
+
34
+ * Set up with one command: the chat bubble then shows on every page, with no
35
+ template changes.
36
+ * Or chat buttons only where you want them, with a template tag.
37
+ * Bubble, sidebar or bottom-bar layout, light / dark / automatic theme and accent
38
+ colour: set in your Kolossus dashboard, or overridden in settings.
39
+ * Bubble on the bottom right or left, its distance from the edges, and its size.
40
+ * What happens on page load: remember each visitor's last state, always open, or
41
+ start minimized.
42
+ * Optional: logged-in users chat under their own name with their history kept. The
43
+ widget secret stays on your server; only an HMAC signature reaches the browser.
44
+
45
+ You need a Kolossus account and a widget created in the Kolossus dashboard.
46
+
47
+ ## Install with one command
48
+
49
+ In Kolossus, open your widget's **Plugins → Django → Copy command**. Then, in your
50
+ project folder (the one with `manage.py`) and with your project's virtualenv active,
51
+ paste and run it. It looks like this, with your own widget token:
52
+
53
+ ```sh
54
+ pip install kolossus-chat-django && kolossus-chat-setup wt_YOUR_WIDGET_TOKEN
55
+ ```
56
+
57
+ Restart your site, and the chat bubble shows on every page. (In Windows PowerShell 5,
58
+ which has no `&&`, run the two commands one after the other.)
59
+
60
+ The Host URL defaults to the Kolossus cloud (`https://engine.kolossus.ai`). For another
61
+ Kolossus server, add `--host https://your-kolossus-server`; the copied command already
62
+ has it when you need it.
63
+
64
+ You can also download the plugin as a zip from the same Plugins sheet; it holds your
65
+ Host URL and widget token, so there the command is
66
+ `pip install kolossus-chat-django.zip && kolossus-chat-setup`.
67
+
68
+ `kolossus-chat-setup` (also `python -m kolossus_chat`) never changes your existing
69
+ lines. It saves a backup (`settings.py.kolossus-backup`) and adds one marked block to
70
+ the end of your settings file:
71
+
72
+ * `kolossus_chat` in `INSTALLED_APPS` and `KolossusChatMiddleware` in `MIDDLEWARE`,
73
+ each only if missing;
74
+ * your Host URL and widget token in `KOLOSSUS_CHAT`, so they are kept when you later
75
+ upgrade (`pip install -U kolossus-chat-django`). Values you set yourself win,
76
+ except empty ones.
77
+
78
+ Running it again changes nothing, except with another widget token or host (or a newer
79
+ zip from the dashboard): then it updates the Host URL and widget token in the block.
80
+ `kolossus-chat-setup --undo` removes the block. If
81
+ your project keeps settings in several files (for example `settings/prod.py`), run it
82
+ for each one: `kolossus-chat-setup --settings mysite.settings.prod`.
83
+
84
+ The middleware adds the chat just before `</body>` of every full HTML page. It leaves
85
+ alone Django admin sites, the Django REST framework browsable API, API docs pages
86
+ (drf-spectacular, drf-yasg, django-ninja), non-HTML responses (JSON, files,
87
+ downloads), error pages, and any page that already uses a `kolossus_chat` template
88
+ tag or has a `data-kolossus` element or the widget script. To leave out more pages,
89
+ list their URL prefixes in `"EXCLUDE_PATHS"`, for example `["/checkout/"]`. To turn
90
+ the site-wide bubble off and place the chat only with template tags, set
91
+ `"SITEWIDE": False`.
92
+
93
+ ## Install by hand
94
+
95
+ ```sh
96
+ pip install kolossus-chat-django
97
+ ```
98
+
99
+ Add the app and make sure the `request` context processor is enabled (it is in
100
+ Django's default project template). Add the middleware for a bubble on every page, or
101
+ leave it out and use the template tags below:
102
+
103
+ ```python
104
+ INSTALLED_APPS = [
105
+ # ...
106
+ "kolossus_chat",
107
+ ]
108
+
109
+ MIDDLEWARE = [
110
+ # ...
111
+ "kolossus_chat.middleware.KolossusChatMiddleware", # optional: bubble on every page
112
+ ]
113
+
114
+ TEMPLATES = [
115
+ {
116
+ "BACKEND": "django.template.backends.django.DjangoTemplates",
117
+ "APP_DIRS": True,
118
+ "OPTIONS": {
119
+ "context_processors": [
120
+ "django.template.context_processors.request",
121
+ # ...
122
+ ],
123
+ },
124
+ },
125
+ ]
126
+ ```
127
+
128
+ ## Settings
129
+
130
+ 1. In your Kolossus dashboard, create a widget for your assistant and add your site's
131
+ domain (for example `example.org`) to its **allowed domains**.
132
+ 2. Add its Host URL and public widget token to `settings.py`:
133
+
134
+ ```python
135
+ KOLOSSUS_CHAT = {
136
+ "HOST_URL": "https://app.kolossus.ai", # your Kolossus server; https:// only
137
+ "WIDGET_TOKEN": "wt_...", # the public token, starts with wt_
138
+
139
+ # Optional
140
+ "WIDGET_SECRET": os.environ.get("KOLOSSUS_WIDGET_SECRET", ""), # ws_..., verified chat
141
+ "THEME": "", # "" = follow the visitor's device, "light", "dark"
142
+ "PRIMARY_COLOR": "", # "" = dashboard colour, or "#rrggbb"
143
+ "LAYOUT": "", # "" = dashboard layout, "bubble", "sidebar", "bottom_bar"
144
+ "OPEN_ON_LOAD": "remember", # "remember", "open", "closed"
145
+ "SITEWIDE": True, # False = the middleware adds nothing; use the template tags
146
+ "EXCLUDE_PATHS": [], # URL prefixes without the bubble, e.g. ["/checkout/"]
147
+ "POSITION": "", # bubble corner: "" = bottom right, "right", "left"
148
+ "OFFSET_X": "", # bubble distance from the side edge, 0-1000 px ("" = 24)
149
+ "OFFSET_Y": "", # bubble distance from the bottom edge, 0-1000 px ("" = 24)
150
+ "BUBBLE_SIZE": "", # "" = medium, "small", "medium", "large"
151
+ }
152
+ ```
153
+
154
+ Anything left empty uses the look set for the widget in your Kolossus dashboard.
155
+ `POSITION`, `OFFSET_X`, `OFFSET_Y` and `BUBBLE_SIZE` apply to the bubble layout.
156
+ `http://` is accepted only for a Kolossus server on `localhost` (local testing).
157
+ Invalid values are ignored with a logged warning, and `manage.py check` reports them
158
+ (`kolossus_chat.W001` to `W015`).
159
+
160
+ | `OPEN_ON_LOAD` | On page load or refresh |
161
+ |---|---|
162
+ | `remember` (default) | As the visitor last left it (open or minimized); open on a first visit |
163
+ | `open` | Always open |
164
+ | `closed` | Only the bubble or tab shows until the visitor clicks it |
165
+
166
+ Clicking a chat button always opens the chat.
167
+
168
+ ### The widget secret
169
+
170
+ `WIDGET_SECRET` is optional. When it is set, each logged-in user's email is signed
171
+ with it (HMAC-SHA256) and the signature is passed to the chat. Kolossus checks the
172
+ signature, so those users get a verified chat under their own name and keep their
173
+ history. Visitors who are not logged in chat anonymously.
174
+
175
+ Keep the secret on the server: load it from an environment variable, never commit
176
+ it, and never put it in a template or `WIDGET_TOKEN`. The tags only ever output the
177
+ public token and the signature.
178
+
179
+ ## Use in templates
180
+
181
+ Not needed with the middleware. Use them to place the chat yourself:
182
+
183
+ ```django
184
+ {% load kolossus_chat %}
185
+
186
+ {# Chat bubble: put it in your base template, before </body> #}
187
+ {% kolossus_chat_widget %}
188
+
189
+ {# A button that opens the chat #}
190
+ {% kolossus_chat_button "Ask our assistant" class="btn btn-primary" %}
191
+
192
+ {# Only the widget script, if you write your own data-kolossus trigger elements #}
193
+ {% kolossus_chat_script %}
194
+ ```
195
+
196
+ The widget script is output once per request, however many tags a page uses. Without
197
+ a valid `HOST_URL` and `WIDGET_TOKEN` the tags output nothing.
198
+
199
+ To hide the bubble on some pages, list them in `"EXCLUDE_PATHS"`. Or set
200
+ `"SITEWIDE": False` and leave `{% kolossus_chat_widget %}` out of those templates (for
201
+ example with a `{% block %}` that the page overrides).
202
+
203
+ ## Content Security Policy
204
+
205
+ If your site sends a CSP header, allow your Kolossus host in `script-src` and in
206
+ `connect-src`, both `https://` and `wss://` (the chat uses a WebSocket):
207
+
208
+ ```
209
+ script-src 'self' https://app.kolossus.ai;
210
+ connect-src 'self' https://app.kolossus.ai wss://app.kolossus.ai;
211
+ ```
212
+
213
+ ## Privacy
214
+
215
+ This package connects your site to the Kolossus service. The chat script
216
+ (`widget.js`) loads from your Kolossus Host URL. When the page loads, the visitor's
217
+ browser sends your widget token to load the chat settings. When the visitor chats, it
218
+ sends their messages, any files they attach, their IP address and approximate
219
+ location (city and country) to the Kolossus server so the assistant can reply. With
220
+ `WIDGET_SECRET` set, logged-in users' email, name and signature are sent too. Answers
221
+ are generated by AI and may be inaccurate. Mention this in your privacy policy.
222
+
223
+ Kolossus terms of service: https://kolossus.ai/terms. Privacy policy:
224
+ https://kolossus.ai/privacy.
225
+
226
+ ## Development
227
+
228
+ ```sh
229
+ python runtests.py
230
+ ```
231
+
232
+ ## Licence
233
+
234
+ BSD 3-Clause. See `LICENSE`.
@@ -0,0 +1,206 @@
1
+ # KolossusAI Chat for Django
2
+
3
+ Add a Kolossus AI assistant to your Django site, as a chat bubble on every page or as
4
+ a button wherever you place a template tag.
5
+
6
+ * Set up with one command: the chat bubble then shows on every page, with no
7
+ template changes.
8
+ * Or chat buttons only where you want them, with a template tag.
9
+ * Bubble, sidebar or bottom-bar layout, light / dark / automatic theme and accent
10
+ colour: set in your Kolossus dashboard, or overridden in settings.
11
+ * Bubble on the bottom right or left, its distance from the edges, and its size.
12
+ * What happens on page load: remember each visitor's last state, always open, or
13
+ start minimized.
14
+ * Optional: logged-in users chat under their own name with their history kept. The
15
+ widget secret stays on your server; only an HMAC signature reaches the browser.
16
+
17
+ You need a Kolossus account and a widget created in the Kolossus dashboard.
18
+
19
+ ## Install with one command
20
+
21
+ In Kolossus, open your widget's **Plugins → Django → Copy command**. Then, in your
22
+ project folder (the one with `manage.py`) and with your project's virtualenv active,
23
+ paste and run it. It looks like this, with your own widget token:
24
+
25
+ ```sh
26
+ pip install kolossus-chat-django && kolossus-chat-setup wt_YOUR_WIDGET_TOKEN
27
+ ```
28
+
29
+ Restart your site, and the chat bubble shows on every page. (In Windows PowerShell 5,
30
+ which has no `&&`, run the two commands one after the other.)
31
+
32
+ The Host URL defaults to the Kolossus cloud (`https://engine.kolossus.ai`). For another
33
+ Kolossus server, add `--host https://your-kolossus-server`; the copied command already
34
+ has it when you need it.
35
+
36
+ You can also download the plugin as a zip from the same Plugins sheet; it holds your
37
+ Host URL and widget token, so there the command is
38
+ `pip install kolossus-chat-django.zip && kolossus-chat-setup`.
39
+
40
+ `kolossus-chat-setup` (also `python -m kolossus_chat`) never changes your existing
41
+ lines. It saves a backup (`settings.py.kolossus-backup`) and adds one marked block to
42
+ the end of your settings file:
43
+
44
+ * `kolossus_chat` in `INSTALLED_APPS` and `KolossusChatMiddleware` in `MIDDLEWARE`,
45
+ each only if missing;
46
+ * your Host URL and widget token in `KOLOSSUS_CHAT`, so they are kept when you later
47
+ upgrade (`pip install -U kolossus-chat-django`). Values you set yourself win,
48
+ except empty ones.
49
+
50
+ Running it again changes nothing, except with another widget token or host (or a newer
51
+ zip from the dashboard): then it updates the Host URL and widget token in the block.
52
+ `kolossus-chat-setup --undo` removes the block. If
53
+ your project keeps settings in several files (for example `settings/prod.py`), run it
54
+ for each one: `kolossus-chat-setup --settings mysite.settings.prod`.
55
+
56
+ The middleware adds the chat just before `</body>` of every full HTML page. It leaves
57
+ alone Django admin sites, the Django REST framework browsable API, API docs pages
58
+ (drf-spectacular, drf-yasg, django-ninja), non-HTML responses (JSON, files,
59
+ downloads), error pages, and any page that already uses a `kolossus_chat` template
60
+ tag or has a `data-kolossus` element or the widget script. To leave out more pages,
61
+ list their URL prefixes in `"EXCLUDE_PATHS"`, for example `["/checkout/"]`. To turn
62
+ the site-wide bubble off and place the chat only with template tags, set
63
+ `"SITEWIDE": False`.
64
+
65
+ ## Install by hand
66
+
67
+ ```sh
68
+ pip install kolossus-chat-django
69
+ ```
70
+
71
+ Add the app and make sure the `request` context processor is enabled (it is in
72
+ Django's default project template). Add the middleware for a bubble on every page, or
73
+ leave it out and use the template tags below:
74
+
75
+ ```python
76
+ INSTALLED_APPS = [
77
+ # ...
78
+ "kolossus_chat",
79
+ ]
80
+
81
+ MIDDLEWARE = [
82
+ # ...
83
+ "kolossus_chat.middleware.KolossusChatMiddleware", # optional: bubble on every page
84
+ ]
85
+
86
+ TEMPLATES = [
87
+ {
88
+ "BACKEND": "django.template.backends.django.DjangoTemplates",
89
+ "APP_DIRS": True,
90
+ "OPTIONS": {
91
+ "context_processors": [
92
+ "django.template.context_processors.request",
93
+ # ...
94
+ ],
95
+ },
96
+ },
97
+ ]
98
+ ```
99
+
100
+ ## Settings
101
+
102
+ 1. In your Kolossus dashboard, create a widget for your assistant and add your site's
103
+ domain (for example `example.org`) to its **allowed domains**.
104
+ 2. Add its Host URL and public widget token to `settings.py`:
105
+
106
+ ```python
107
+ KOLOSSUS_CHAT = {
108
+ "HOST_URL": "https://app.kolossus.ai", # your Kolossus server; https:// only
109
+ "WIDGET_TOKEN": "wt_...", # the public token, starts with wt_
110
+
111
+ # Optional
112
+ "WIDGET_SECRET": os.environ.get("KOLOSSUS_WIDGET_SECRET", ""), # ws_..., verified chat
113
+ "THEME": "", # "" = follow the visitor's device, "light", "dark"
114
+ "PRIMARY_COLOR": "", # "" = dashboard colour, or "#rrggbb"
115
+ "LAYOUT": "", # "" = dashboard layout, "bubble", "sidebar", "bottom_bar"
116
+ "OPEN_ON_LOAD": "remember", # "remember", "open", "closed"
117
+ "SITEWIDE": True, # False = the middleware adds nothing; use the template tags
118
+ "EXCLUDE_PATHS": [], # URL prefixes without the bubble, e.g. ["/checkout/"]
119
+ "POSITION": "", # bubble corner: "" = bottom right, "right", "left"
120
+ "OFFSET_X": "", # bubble distance from the side edge, 0-1000 px ("" = 24)
121
+ "OFFSET_Y": "", # bubble distance from the bottom edge, 0-1000 px ("" = 24)
122
+ "BUBBLE_SIZE": "", # "" = medium, "small", "medium", "large"
123
+ }
124
+ ```
125
+
126
+ Anything left empty uses the look set for the widget in your Kolossus dashboard.
127
+ `POSITION`, `OFFSET_X`, `OFFSET_Y` and `BUBBLE_SIZE` apply to the bubble layout.
128
+ `http://` is accepted only for a Kolossus server on `localhost` (local testing).
129
+ Invalid values are ignored with a logged warning, and `manage.py check` reports them
130
+ (`kolossus_chat.W001` to `W015`).
131
+
132
+ | `OPEN_ON_LOAD` | On page load or refresh |
133
+ |---|---|
134
+ | `remember` (default) | As the visitor last left it (open or minimized); open on a first visit |
135
+ | `open` | Always open |
136
+ | `closed` | Only the bubble or tab shows until the visitor clicks it |
137
+
138
+ Clicking a chat button always opens the chat.
139
+
140
+ ### The widget secret
141
+
142
+ `WIDGET_SECRET` is optional. When it is set, each logged-in user's email is signed
143
+ with it (HMAC-SHA256) and the signature is passed to the chat. Kolossus checks the
144
+ signature, so those users get a verified chat under their own name and keep their
145
+ history. Visitors who are not logged in chat anonymously.
146
+
147
+ Keep the secret on the server: load it from an environment variable, never commit
148
+ it, and never put it in a template or `WIDGET_TOKEN`. The tags only ever output the
149
+ public token and the signature.
150
+
151
+ ## Use in templates
152
+
153
+ Not needed with the middleware. Use them to place the chat yourself:
154
+
155
+ ```django
156
+ {% load kolossus_chat %}
157
+
158
+ {# Chat bubble: put it in your base template, before </body> #}
159
+ {% kolossus_chat_widget %}
160
+
161
+ {# A button that opens the chat #}
162
+ {% kolossus_chat_button "Ask our assistant" class="btn btn-primary" %}
163
+
164
+ {# Only the widget script, if you write your own data-kolossus trigger elements #}
165
+ {% kolossus_chat_script %}
166
+ ```
167
+
168
+ The widget script is output once per request, however many tags a page uses. Without
169
+ a valid `HOST_URL` and `WIDGET_TOKEN` the tags output nothing.
170
+
171
+ To hide the bubble on some pages, list them in `"EXCLUDE_PATHS"`. Or set
172
+ `"SITEWIDE": False` and leave `{% kolossus_chat_widget %}` out of those templates (for
173
+ example with a `{% block %}` that the page overrides).
174
+
175
+ ## Content Security Policy
176
+
177
+ If your site sends a CSP header, allow your Kolossus host in `script-src` and in
178
+ `connect-src`, both `https://` and `wss://` (the chat uses a WebSocket):
179
+
180
+ ```
181
+ script-src 'self' https://app.kolossus.ai;
182
+ connect-src 'self' https://app.kolossus.ai wss://app.kolossus.ai;
183
+ ```
184
+
185
+ ## Privacy
186
+
187
+ This package connects your site to the Kolossus service. The chat script
188
+ (`widget.js`) loads from your Kolossus Host URL. When the page loads, the visitor's
189
+ browser sends your widget token to load the chat settings. When the visitor chats, it
190
+ sends their messages, any files they attach, their IP address and approximate
191
+ location (city and country) to the Kolossus server so the assistant can reply. With
192
+ `WIDGET_SECRET` set, logged-in users' email, name and signature are sent too. Answers
193
+ are generated by AI and may be inaccurate. Mention this in your privacy policy.
194
+
195
+ Kolossus terms of service: https://kolossus.ai/terms. Privacy policy:
196
+ https://kolossus.ai/privacy.
197
+
198
+ ## Development
199
+
200
+ ```sh
201
+ python runtests.py
202
+ ```
203
+
204
+ ## Licence
205
+
206
+ BSD 3-Clause. See `LICENSE`.
@@ -0,0 +1,3 @@
1
+ """KolossusAI Chat for Django: template tags that embed the Kolossus chat widget."""
2
+
3
+ __version__ = "1.3.0"
@@ -0,0 +1,6 @@
1
+ """python -m kolossus_chat: the same as kolossus-chat-setup."""
2
+ import sys
3
+
4
+ from .setup_cli import main
5
+
6
+ sys.exit(main())
@@ -0,0 +1,10 @@
1
+ from django.apps import AppConfig
2
+
3
+
4
+ class KolossusChatConfig(AppConfig):
5
+ name = "kolossus_chat"
6
+ verbose_name = "KolossusAI Chat"
7
+
8
+ def ready(self):
9
+ # Registers the configuration system check.
10
+ from . import checks # noqa: F401
@@ -0,0 +1,20 @@
1
+ from django.core.checks import Tags, Warning, register
2
+
3
+ from .conf import W_NOT_CONFIGURED, load_config
4
+
5
+
6
+ @register(Tags.templates)
7
+ def check_kolossus_chat_settings(app_configs=None, **kwargs):
8
+ """Warn about a missing or invalid KOLOSSUS_CHAT setting."""
9
+ cfg = load_config()
10
+ messages = [
11
+ Warning(message, hint="See the KOLOSSUS_CHAT section of the kolossus-chat-django README.", id=f"kolossus_chat.{code}")
12
+ for code, message in cfg.problems
13
+ ]
14
+ if not cfg.configured:
15
+ messages.append(Warning(
16
+ "KolossusAI Chat is not showing yet: set KOLOSSUS_CHAT['HOST_URL'] and KOLOSSUS_CHAT['WIDGET_TOKEN'].",
17
+ hint="Copy both from the widget in your Kolossus dashboard.",
18
+ id=f"kolossus_chat.{W_NOT_CONFIGURED}",
19
+ ))
20
+ return messages