Skip to Content
WidgetInstallation

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

  1. Create a Knoku project.
  2. Copy the Project ID from the dashboard.
  3. Add the site host under Project -> Settings -> Domains.
  4. 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.com

If 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/widget
import { 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}
ResponseMeaningFix
200 with "active": trueConfig loaded and the widget can mountIf no launcher appears, check the console
200 with "active": falseProject or billing state blocks chatRead disabled_reason
403Origin not allowedAdd the exact host/origin under Settings -> Domains
404Project not foundCheck data-project-id

Common disabled reasons:

ReasonWhat to do
project_draftSet the project live
project_pausedUnpause the project
monthly free plan limit reachedUpgrade or wait for the next billing period
monthly trial limit reachedAdd a payment method before trial ends or wait for the next period
monthly plan limit reachedUpgrade or wait for the next billing period
monthly plan limit reached; enable overage to continueEnable overage or wait for the next period
overage spending limit reachedRaise the overage cap or wait for the next period
organization is not activeFix workspace billing or status

Console checks

MessageMeaning
Knoku: data-project-id is requiredThe script is missing data-project-id
Knoku: invalid value for data-X, using defaultAn enum, hex color, or language value is invalid
Knoku: support form deflector requires a Business plandata-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

Platform guides

Last updated on