Skip to content
EveryKnockHelp

Your chat on your website

Embed and attributes

Who can open itViewer: noOperator: noSupervisor: noAdmin: yes

This page is for whoever adds the chat to the website.

Ask an Admin of your company’s EveryKnock for two things, both in the install steps of the Chat studio page (Add to website, or Website & code once the chat is live):

  • The code, from the step Put the code on your site. It holds your site key and the script’s address. The samples below use YOUR_SITE_KEY and the production script.
  • Your website on the list, at the step Say where it runs: every domain that will show the chat, such as example.com (which covers www.example.com and other subdomains), your staging site, and localhost while you build. On a website that is not listed the chat is not drawn. A demo website the platform gives your company runs the chat without being listed (Chat studio).

Put the script in the page’s <head> and the element where the chat belongs.

<script defer src="https://cdn.everyknock.ai/widget/everyknock.js"></script>
<everyknock-chat
site-key="YOUR_SITE_KEY"
mode="floating"
position="bottom-right"
></everyknock-chat>
  • defer keeps the script from holding up the page. crossorigin="anonymous" on the tag is fine too.
  • Floating: make the element a direct child of <body>. A parent with transform, filter, perspective, will-change or contain: paint places the floating window against that parent instead of the screen.
  • One chat per page: every <everyknock-chat> on a page shares one chat. A second element naming a different site-key, api-url or font-url from the first is not drawn, and the browser console says why.
  • Stacking: the launcher sits at z-index 9999, the window and the nudge one below. Set --everyknock-z-index on the element to move all three.
  • A printed page leaves out the launcher and the floating window; an inline chat prints with the page.
mode="inline" (the default) mode="floating"
Where Inside the page, filling its element A launcher in a corner; the window opens above the page
Loads the chat script At once When the visitor opens it (started on hover, focus or touch), or once the page is idle for a visitor with a chat still open or a nudge to show
Size Its element’s 400 by 640 px; full screen on a phone

The chat fills its element and is min(640px, 80vh) tall unless you set a height. Reserve the space so the page does not move when the chat arrives.

<div style="min-height: 640px">
<everyknock-chat site-key="YOUR_SITE_KEY" mode="inline"></everyknock-chat>
</div>

Copy this component into your app and render it once, near the root.

import { createElement, useEffect } from 'react';
const SCRIPT_URL = 'https://cdn.everyknock.ai/widget/everyknock.js';
export function EveryKnockWidget() {
// Load the widget script once, however many times this renders.
useEffect(() => {
if (document.querySelector(`script[src="${SCRIPT_URL}"]`)) return;
const script = document.createElement('script');
script.src = SCRIPT_URL;
script.defer = true;
document.head.append(script);
}, []);
return createElement('everyknock-chat', { 'site-key': 'YOUR_SITE_KEY', mode: 'floating', position: 'bottom-right' });
}

In Google Tag Manager or a similar tool, add a custom HTML tag that fires on all pages. Nothing on the site itself changes.

<script>
(function () {
var loader = document.createElement('script');
loader.src = 'https://cdn.everyknock.ai/widget/everyknock.js';
loader.defer = true;
document.head.appendChild(loader);
var widget = document.createElement('everyknock-chat');
widget.setAttribute('site-key', 'YOUR_SITE_KEY');
widget.setAttribute('mode', 'floating');
widget.setAttribute('position', 'bottom-right');
document.body.appendChild(widget);
})();
</script>

The site-key names your company’s chat. It is public, like a publishable key, and grants nothing. A key may start with a few letters and underscores, such as xm_p_: that is part of the key and tells the widget which EveryKnock service your chat is on, so paste the key whole, as the Chat studio shows it. The chat starts only on the websites listed under Say where it runs in the Chat studio’s install steps (a domain covers its subdomains). From any other website the settings request is refused (403) and no chat is drawn; a wrong key is answered 404.

Every attribute is optional.

Attribute Default What it does
site-key none Your company’s public key
mode inline inline or floating
position bottom-right For floating: bottom-right or bottom-left, on a phone too
scheme The dashboard’s light, dark or auto (the visitor’s device setting), for a page with its own switch (below)
font-url The widget’s own copy Where the look’s font comes from (below)
lang en The language of the chat’s own words, for screen readers. Set it when you translate them
api-url Built into the widget Leave it out: the widget already knows its service’s address, from your site key

There is no attribute for a colour, a name, a picture, the welcome message or a feature. An admin sets those on the Chat studio page, and nothing on the element overrides them.

The device font needs no file. Any other font the look uses is served from the same address as the widget script, never from Google Fonts. font-url="" loads nothing, for a page that already serves the faces itself; an address loads that stylesheet instead.

The dashboard decides whether the chat is light or dark. A page with its own switch tells the chat which one it is showing, with the attribute or from script:

document.querySelector('everyknock-chat').scheme = 'dark';

An empty value hands the choice back to the dashboard. This is the one part of the look a page sets.

The chat is drawn only once its settings have arrived. The page asks once, asks once more if that fails, and gives up after about 4 seconds. If nothing usable arrives (the service cannot be reached, the site key is wrong, or the website is not listed), nothing is drawn for that page view: no launcher, no outline. The page stays as it was, and the console logs one warning saying why:

The console says What it means What to do
“EveryKnock widget: not drawn, because GET …/chat/config answered 403. The page is left as it is.” The website is not on the company’s list Ask an Admin to list this domain under Say where it runs
The same, with “answered 404” The site key is wrong or missing Copy the code again from the Chat studio
The same, with “could not be reached” or “did not answer within 4 seconds” The request was blocked, or the service did not answer Check the page’s security policy (Security policy and browsers), a content blocker and the connection
“EveryKnock widget: this page already has a <everyknock-chat> that names another API, company or font stylesheet…” Two different embeds are on one page, and the second is not drawn Keep one
“EveryKnock widget: more than one <everyknock-chat> is on this page. They share a single conversation; use one.” The same embed is on the page twice Remove one

Content inside the element stays visible in that case and is hidden once the chat is drawn:

<everyknock-chat site-key="YOUR_SITE_KEY" mode="inline">
<p>The assistant is not available. <a href="mailto:hello@inkreda.example">Email us</a>.</p>
</everyknock-chat>

The element also fires a bubbling everyknock-unavailable event with the reason in event.detail.reason:

document.addEventListener('everyknock-unavailable', (event) => {
console.info('The chat is not drawn:', event.detail.reason);
});

A chat that was drawn and then fails to load its script says “Chat unavailable — try again” on the button: Errors and notices.

Property What it does
el.strings = { … } Replaces any of the chat’s own words, over the dashboard’s (Wording and strings)
el.scheme The same as the scheme attribute
el.startNewConversation(message?) Forgets the visitor’s chat on this device and starts a fresh one in place, keeping any unsent text, like the chat’s own Start a new chat. With a message (trimmed, at most 1,000 characters), it is sent as the visitor’s first message and a floating window opens. A message given before the chat is ready is sent once it is drawn

strings and scheme can be set at any time, before or after the chat’s script has run. The method exists only once the script has run. The script is deferred, so wait for the element before you call it:

customElements.whenDefined('everyknock-chat').then(() => {
const chat = document.querySelector('everyknock-chat');
document.querySelector('#ask-about-pricing').addEventListener('click', () => {
chat.startNewConversation('What does it cost?');
});
});

A reload never starts a new chat: an open chat resumes so a team member’s reply is not lost. To offer a way to start over, wire your own button to startNewConversation(). The chat has ended when the element’s shadow root holds an element with data-role="ended".

With each message the chat sends the page’s address and the referring page, both cut to the site and path: the query string and the fragment are dropped, except the five utm_ campaign tags of the page’s address, which your team sees as where the visitor came from. It also sends the browser’s language and time zone. It reads nothing else from your page.

The chat draws inside a shadow root: your page’s styles do not reach it and its styles do not leak out. It resets inherited styles, sizes in px (so your root font size does not change it), keeps its frame left to right on a right-to-left page while messages take their own direction, and reads no colour from your page. Your page keeps control of the element’s own display, margin, width and height.

Yes: the chat can be a chat screen in your app. Your app’s developer shows, in a WebView, a page on one of your listed websites that holds only the chat (<everyknock-chat mode="inline" style="height:100vh">). A page the app builds itself is refused unless it names a listed website as its base address.

The app allows So that
JavaScript and storage (Android javaScriptEnabled and domStorageEnabled; React Native javaScriptEnabled and domStorageEnabled) The chat draws, and a returning visitor finds their conversation
The microphone (iOS NSMicrophoneUsageDescription, Android RECORD_AUDIO, and the WebView’s permission request) Voice messages can be recorded
File picking (Android onShowFileChooser) Visitors can attach files
Links opened in the phone’s browser A source or your booking page does not replace the chat

It needs iOS 16.4 or later, or Android with a current System WebView. A visitor whose app is closed is not notified when your team replies: they see the reply when they open the chat again.

Reviewed

Source files for this page
  • apps/widget/README.md
  • apps/widget/src/config.ts
  • apps/widget/src/config-request.ts
  • apps/widget/src/launcher-shared.ts
  • apps/widget/src/loader.ts
  • apps/widget/src/element.tsx
  • apps/widget/src/look.ts
  • apps/widget/src/chatbot/useIntakeChat.ts
  • apps/widget/examples/
  • apps/dashboard/src/views/chatstudio/EmbedGuide.tsx
  • shared/web/src/views/install/samples.ts
  • apps/dashboard/src/views/install/AllowedWebsites.tsx
  • services/api/app/visitors/widget_origins.py
  • docs/SETTINGS.md