Installation
Add the widget once in the global layout that renders on every page where visitors should ask questions.
Only data-project-id is required.
Before you start
- Create a Knoku project.
- Copy the Project ID from the dashboard.
- Add the site host under Project -> Settings -> Domains.
- Index at least one Public source.
Allowed domain entries may be bare hosts (docs.example.com) or origins with scheme and port (https://docs.example.com, http://localhost:3000). Match the host visitors actually use. Wildcards are not supported.
If your site uses Content Security Policy, allow the widget script and API calls:
script-src https://cdn.knoku.com
connect-src https://api.knoku.comIf Turnstile is enabled, also allow Cloudflare. See Turnstile CSP.
CDN script
<script
async
src="https://cdn.knoku.com/widget.js"
data-project-id="YOUR_PROJECT_ID"
></script>The CDN bundle self-initializes from the script tag attributes. Add optional attributes from the Attributes reference to customize copy, layout, color, language, consent, and behavior.
npm
Use the npm package when your app controls widget mounting from JavaScript.
npm install @knoku/widgetimport { initKnokuWidget } from '@knoku/widget'
await initKnokuWidget({
projectId: 'YOUR_PROJECT_ID',
})initKnokuWidget() resolves after the widget has mounted. It also sets window.Knoku for runtime control. See Runtime API.
Verify
Open the site and check the browser network tab for:
GET https://api.knoku.com/api/v1/config/{projectId}| Response | Meaning | Fix |
|---|---|---|
200 with "active": true | Config loaded and the widget can mount | If no launcher appears, check the console |
200 with "active": false | Project or billing state blocks chat | Read disabled_reason |
403 | Origin not allowed | Add the exact host/origin under Settings -> Domains |
404 | Project not found | Check data-project-id |
Common disabled reasons:
| Reason | What to do |
|---|---|
project_draft | Set the project live |
project_paused | Unpause the project |
monthly free plan limit reached | Upgrade or wait for the next billing period |
monthly trial limit reached | Add a payment method before trial ends or wait for the next period |
monthly plan limit reached | Upgrade or wait for the next billing period |
monthly plan limit reached; enable overage to continue | Enable overage or wait for the next period |
overage spending limit reached | Raise the overage cap or wait for the next period |
organization is not active | Fix workspace billing or status |
Console checks
| Message | Meaning |
|---|---|
Knoku: data-project-id is required | The script is missing data-project-id |
Knoku: invalid value for data-X, using default | An enum, hex color, or language value is invalid |
Knoku: support form deflector requires a Business plan | data-mode="deflector" is configured but the project is not eligible |
Knoku: data-form-selector is required for data-mode="deflector" | Deflector mode needs a form selector |