Chat how-to
Short recipes for the Knock chat with @knock-ai/sdk. Each one says when to use it, where the code goes, and what the visitor sees.
Each recipe on this page does one task with knock.chat. It says when to use it, where the code goes, and what the visitor sees. For what you need from Knock before you start, see Chat. To see the looks without code, open the chat playground.
Set up the chat once, at app start
Use it when: you add the chat to your app. The other recipes start from here.
Call knock.init() one time, in the browser, when your app starts. Put the chat's options in chat. The chat gets these options before any other call. That includes the calls you made before init().
The example runs your live chat on your production origin only. Every other origin gets test mode, for example localhost, staging or a preview deployment. Test mode runs a scripted conversation. It sends nothing to Knock. It needs no magic link and no allowed origin.
import { knock } from '@knock-ai/sdk';
// The origin Knock allows for your live chat: scheme, host and port.
const LIVE_ORIGIN = 'https://www.acme.com';
knock.init({
tagId: 'YOUR_TAG_ID',
chat: {
...(window.location.origin === LIVE_ORIGIN ? { magicLinkId: 'YOUR_MAGIC_LINK_ID' } : { test: true }),
brandName: 'Acme',
},
});- Call
init()in one place only. A second call does nothing. It prints a console warning. KnockProvideralso callsinit(). It takeschatas a prop. UseKnockProvideror this component, not both.chatininit()needs@knock-ai/sdk0.1.4 or later. An older SDK dropschatand gives no warning. Then your live chat runs where you expect test mode. To see your version, readknock.version.- You can call the
knock.chatmethods before your Knock tag is ready. The calls wait and run in order. On the server, they do nothing. - Test mode stays on until the page reloads.
test: falsedoes not turn it off. So choose test or live one time, ininit().
What the visitor sees
- On your live origin: the chat's bubble in the corner. A click on it opens your live chat.
- On every other origin: the same chat, with a scripted conversation. An amber "Test" pill shows before the send button. A TEST badge shows on the bubble.
- In test mode: Telegram and Slack buttons under "Continue in your own apps". On your live origin, they show when Knock offers those apps for your magic link: see Before you start.
Open the chat from your own button
Use it when: a button or a link on your page opens the chat.
You can do this in two ways:
- Add the
data-knock-chatattribute to your element. The chat handles the click. - Call
knock.chat.open()from your own code.
<button type="button" data-knock-chat>Chat with us</button>
<a href="/contact" data-knock-chat>Talk to sales</a>In React, give the attribute an empty value. A bare data-knock-chat renders as "true". The chat reads a value as the name of a screen.
<button type="button" data-knock-chat="">Chat with us</button>data-knock-chat | knock.chat.open() | |
|---|---|---|
| Where it goes | An attribute on your element | Your click handler, or any other code |
| The chat opens out of | Your element, with the morph motion | The chat's bubble. When no bubble shows, the chat fades in. |
| Before the chat has loaded | The click opens the chat when it has loaded. The chat then opens out of the bubble, or fades in. | The call waits. The chat opens when it has loaded. |
With the SDK, the attribute works after your code uses the chat. chat in init() is enough. With launcher: 'both' (the default) or 'buttons', the chat also finds the elements that your page adds later, for example after a route change. With 'bubble', the chat finds only the elements that are on the page when it loads.
The panel grows out of your element only when the look's motion is 'morph'. 'morph' is the default motion of harbor, nightshift, fieldbook and signal. See Use the morph transition and its effects.
What the visitor sees
- With the
morphmotion, the chat panel grows out of the element. The panel starts in the element's background colour when that colour is at least 50% opaque. An outline or text button cross-fades instead. - With
morph, the element does not show while the chat is open. The panel takes its place. - With
fade,crtorappear, the element stays as it is. - A click on the same element closes the chat.
- A click on another
data-knock-chatelement applies that element's options. The chat stays open. - With
morph, on close, the panel shrinks back into the element when at least half of the element is in view. Otherwise it closes into the bubble. When no bubble shows, it closes toward the nearest edge. - On close, the focus goes back to the element.
- A middle click on a link still opens the link. A click with a modifier key does too.
- When the chat cannot show, the element keeps its own behaviour. For example,
<a href="/contact">still goes to your contact page.
The chat starts to load when the page is idle, after your Knock tag is ready. So for most clicks, the chat has already loaded. A link that opens in the same tab waits for the chat for 2.5 seconds at most. Then the browser follows the link.
The chat sets aria-haspopup="dialog", aria-controls and aria-expanded on the element. It keeps aria-expanded in step with the chat. Use a <button> or an <a href>. The chat gives any other element role="button" and tabindex="0", and handles the Enter and Space keys on it. The console then prints a warning.
Use only your own launcher
Use it when: your page has its own launcher, and you do not want the chat's bubble at first.
- Add
launcher: 'buttons'tochatininit(). - Add
data-knock-chatto your launcher.
knock.init({
tagId: 'YOUR_TAG_ID',
chat: { magicLinkId: 'YOUR_MAGIC_LINK_ID', launcher: 'buttons' },
});<button type="button" data-knock-chat>Chat with us</button>launcher | The chat's bubble | Your data-knock-chat elements |
|---|---|---|
'both' | Shows | Open the chat, also the elements that your page adds later |
'bubble' | Shows | Only the elements on the page when the chat loads open it |
'buttons' | Shows only after the visitor has sent a message | Open the chat, also the elements that your page adds later |
When your code does not set launcher, the chat uses the setting of your Knock tag. When the tag has no setting, the chat uses 'both'.
What the visitor sees
- At first, no bubble shows. Your launcher opens the chat. With the
morphmotion, the chat grows out of your launcher. - The visitor sends a message and closes the chat. Then the chat's bubble scales in at the corner. The bubble leads back to the conversation.
- The chat does not store this. After a page load, the bubble shows again only after the visitor sends another message.
- When no bubble shows, a
knock.chat.open()call has nothing to grow out of. So the chat fades in.
With 'buttons' and no data-knock-chat element on the page after 2 seconds, the console says: Vendor chat: launcher "buttons" found no Knock button on the page. Add data-knock-chat to an element, or use launcher: "both".
An inline chat has no bubble with any launcher. To change the launcher on one page of a single-page app, call knock.chat.configure({ launcher }) on the route change.
Start the conversation with a message
Use it when: a button such as "Book a demo" sends the visitor's first message for them.
From your HTML, add data-knock-send next to data-knock-chat:
<a href="/contact" data-knock-chat data-knock-send="I would like a demo">Book a demo</a>From your code, pass send to open():
knock.chat.open({ send: 'I would like a demo' });To put text in the message box and let the visitor send it, use message. In HTML, use the data-knock-message attribute.
knock.chat.open({ message: 'I have a question about pricing' });- The chat sends
sendonce per conversation. A second click opens the chat and sends nothing. - Each magic link has its own conversation. The chat keeps the sent messages per link.
- When you pass both
sendandmessage, the chat usessendand ignoresmessage. - The chat trims the text and cuts it at 4,000 characters.
- For a returning visitor, the chat waits until the conversation has loaded. It sends the message only when the conversation does not have it yet.
- To suggest first messages that the visitor can pick, pass up to 4
starters. Each one is up to 80 characters. They hide after the visitor's first message.
What the visitor sees
- With
send: the chat opens on the conversation. The message shows as the visitor's. The agent replies. - With
message: the chat opens with the text in the message box. The visitor can change the text before they send it. - In test mode with
test: true, a message about a demo plays thebookingscript. A message that asks for a person plays therepscript.
Brand the chat
Use it when: you want the chat to show your name, your agent, your colour and your bubble.
Put these options in chat in init(). You can also set them later with knock.chat.configure().
knock.init({
tagId: 'YOUR_TAG_ID',
chat: {
magicLinkId: 'YOUR_MAGIC_LINK_ID',
brandName: 'Acme',
agentName: 'Ava',
agentImageUrl: '/images/ava.png',
skin: {
colors: { brand: '#2346D8' },
colorsDark: null,
bubble: { label: 'Chat with us' },
assets: { bubble: '/images/bubble.png' },
},
},
});| Option | What it sets |
|---|---|
brandName | The name in the header, and the message box's placeholder: "Message Acme…". Without it, the header says "Chat". |
agentName | The AI agent's name. Without it, the agent uses brandName. |
agentImageUrl | The agent's picture, in the header and beside its messages. Without it, the agent shows the first letter of brandName on your brand colour. With no brandName, it shows a spark icon. Your reps keep their own photos. |
skin.colors.brand | Your main colour. It colours the buttons. In most looks, it also colours the visitor's messages and the chat's bubble. |
skin.colorsDark: null | The chat makes its dark-mode colours from your brand. |
skin.bubble.label | Text on the bubble. The text turns the bubble into a pill. Up to 24 characters. |
skin.bubble.icon | The bubble's icon, for example 'chat' (the default), 'spark', 'help' or 'calendar'. An unknown name prints a warning. The bubble then shows 'chat'. |
skin.bubble.size | The bubble's size: 44 to 72 pixels. |
skin.assets.bubble | A picture in place of the bubble's icon, with or without a label. When the picture fails to load, the icon shows. |
skin.assets.header | Your logo in the header, in place of the agent's picture. It is as tall as that picture and up to four times as wide. A rep who joins still shows in the header. |
skin.assets.wall | A soft pattern behind the conversation. The chat makes it from the shape of your picture, in the text colour. Use a PNG or SVG with a transparent background. |
- The chat trims
brandNameandagentNameand cuts them at 60 characters. A name that you set in code wins over the name in your Knock tag. - A colour is a hex value,
#RGBor#RRGGBB. Another value, such as'red'or'rgb(…)', prints a console warning. That key then keeps the look's colour. - When you leave out a colour key and the look does not set it, that key follows another key:
userBubble,launcherBg,focusRingandbrandInkfollowbrand.userBubbleTextandlauncherFgfollowonBrand.headerBgfollowsbg.agentBubbleTextandheaderFgfollowtext. - In dark mode, the chat uses
colorsDark, notcolors. So setcolorsDarktoo, orcolorsDark: null, ormode: 'light'. - When
onBrandonbrandis below a 4.5:1 contrast, the chat uses white or a dark ink instead. - The
terminallook reads onlybrandfromcolors. Thepixellook starts from its own palette. - A picture is an
https://orhttp://URL, or a path on your site. The chat ignoresdata:,blob:andjavascript:URLs.nullclears a picture. The chat requests each picture with no referrer. - A wall from another origin needs CORS: its host must send
Access-Control-Allow-Origin. - If you use a Content Security Policy, add the host of your pictures to
img-src. Also adddata:: the wall and the icons of the Telegram and Slack buttons aredata:images. Without it, those buttons show with no icon. - The
terminallook shows no bubble picture.
The other colour keys are onBrand, brandInk, bg, surface, surfaceRaised, text, textMuted, border, userBubble, userBubbleText, agentBubble, agentBubbleText, accent, onAccent, positive, focusRing, launcherBg, launcherFg, headerBg and headerFg (the KnockChatColors type).
What the visitor sees
- The header shows "Acme" and Ava's picture. The message box says "Message Acme…".
- The agent speaks as Ava. Her picture shows beside its messages.
- The buttons and the visitor's messages use your brand colour. In dark mode, the chat makes its colours from your brand colour.
- The bubble is a pill with your picture and "Chat with us".
Pick a look, and follow your site's light or dark mode
Use it when: you want one of Knock's looks, and your site has its own light and dark theme.
| Look | Mode when you set none |
|---|---|
harbor | The visitor's system setting ('auto') |
nightshift | Dark |
fieldbook | Light |
signal | Light |
terminal | Dark |
pixel | The visitor's system setting ('auto') |
mode: 'auto' follows the visitor's system setting, not your site's theme switch. To follow your site, pass 'light' or 'dark'. Then call knock.chat.setSkin() each time your theme changes.
Run this code one time, in the browser, where you call init(). In Next.js, put it in the effect of the KnockChatSetup component from Set up the chat once, at app start.
import { knock } from '@knock-ai/sdk';
import type { KnockChatSkin } from '@knock-ai/sdk';
type Mode = 'light' | 'dark';
// Your site's theme. Here it is a `dark` class on <html>.
const siteMode = (): Mode => (document.documentElement.classList.contains('dark') ? 'dark' : 'light');
// Your whole look: the preset, the mode, and your colours, bubble and motion.
const skinFor = (mode: Mode): KnockChatSkin => ({ preset: 'signal', mode });
let mode = siteMode();
knock.init({
tagId: 'YOUR_TAG_ID',
chat: { magicLinkId: 'YOUR_MAGIC_LINK_ID', skin: skinFor(mode) },
});
new MutationObserver(() => {
if (siteMode() === mode) return;
mode = siteMode();
knock.chat.setSkin(skinFor(mode));
}).observe(document.documentElement, { attributes: true, attributeFilter: ['class'] });When your theme is React state, call setSkin() in an effect:
useEffect(() => knock.chat.setSkin({ preset: 'signal', mode }), [mode]);setSkin()replaces the whole skin that you set from code. It does not merge with the last call. So pass the whole look each time. AftersetSkin({ preset: 'terminal' }), a call tosetSkin({ mode: 'dark' })losesterminal.- A skin that names a
presetdrops the look from your Knock tag. A skin with nopresetgoes on top of your Knock tag's look. knock.chat.resetSkin()drops the look that you set from code. The chat goes back to your Knock tag's look.- To give one page of a single-page app its own look, call
setSkin()on each route change. Pass the whole skin of that page. Useknock.chat.configure()for options such aslauncher. Do not callinit()again.
What the visitor sees
- The chat turns light or dark with your site. The conversation stays.
- When the styles of a new look have not downloaded yet, the chat keeps the current look until they arrive.
Use the morph transition and its effects
Use it when: you want the chat to grow out of its bubble or out of your button, with or without a WebGL effect.
Put motion in the skin:
knock.init({
tagId: 'YOUR_TAG_ID',
chat: {
magicLinkId: 'YOUR_MAGIC_LINK_ID',
skin: {
preset: 'signal',
motion: { preset: 'morph', curve: 'smooth', speed: 1, webgl: 'ripple' },
},
},
});| Key | Values | What it does |
|---|---|---|
preset | 'morph', 'fade', 'crt', 'appear' | The open and close motion. |
curve | 'smooth', 'snappy', 'calm' | The timing. Open and close take 520 and 300 ms with smooth, 360 and 210 ms with snappy, and 720 and 420 ms with calm. |
speed | 0.25 to 2 | The chat divides the durations by it. 2 is twice as fast. |
webgl | 'off', 'liquid', 'ripple', 'dissolve' | A WebGL effect for the morph motion. |
TypeScript does not check the keys inside motion. So check their spelling. An unknown motion.preset prints a console warning, and the chat uses 'morph'. A key that you leave out keeps the look's value:
| Look | Its motion |
|---|---|
harbor | morph, smooth, speed 0.8, webgl: 'liquid' |
nightshift | morph, snappy |
fieldbook | morph, calm, speed 0.72 |
signal | morph, snappy, speed 1.2 |
terminal | fade, snappy |
pixel | appear, smooth, speed 0.8 |
What each motion.preset plays:
'morph': the panel grows out of the bubble, or out of thedata-knock-chatelement that the visitor clicked. On close, it shrinks back. With nothing to grow out of, or on a full-screen panel, it fades.'fade': the panel fades in and out.'crt': a bright line opens into the panel. It plays on every layout.'appear': a short fade with a 4% scale, 200 ms in and 160 ms out at speed 1. It plays on every layout.- With
'morph', a phone sheet slides up, and a sidebar slides in from its edge. - When the visitor's system asks for reduced motion, every open and close is a 160 ms fade, with no WebGL.
- An inline chat has no open or close motion.
The WebGL effect plays only when all of these are true:
motion.webglis'liquid','ripple'or'dissolve', not'off'.motion.presetis'morph'.- The panel opens out of the bubble or out of your element.
- The panel is not a phone sheet, a sidebar or an inline chat.
- The browser has WebGL.
- The visitor's system does not ask for reduced motion.
Otherwise, the chat plays the motion of motion.preset without WebGL. Out of your own element, the effect is always 'liquid', whichever of the three webgl names. 'ripple' and 'dissolve' play out of the bubble only.
What the visitor sees
- With the code above, a click on the bubble grows the panel out of the bubble, with the ripple effect.
- A click on your
data-knock-chatbutton grows the panel out of the button, with the liquid effect.
Show the chat inside your page
Use it when: the chat is part of a page, such as a support page, and does not float.
- Add an empty element with a height.
- Set
containerto that element, or to a CSS selector for it. - To go back to the floating chat, set
containertonull.
<div id="support-chat" style="height: 600px"></div>knock.chat.configure({ container: '#support-chat' });
// Later, back to the floating chat:
knock.chat.configure({ container: null });The chat looks up a selector one time: when the chat loads, or when you set the selector after that. In a single-page app, the element can be missing from the page at that time. So pass the element itself from the component that renders it. When the component unmounts, set container to null. See the React example in Show it inside your page. In Vue, do it in onMounted with a template ref. In Angular, do it in ngAfterViewInit with an ElementRef's nativeElement.
configure({ container }) with | What happens |
|---|---|
| Another element | The chat moves there. The conversation stays. |
| The element the chat is in | Nothing changes. |
null | The floating chat comes back, closed. The conversation stays. The visitor loses a message that they were typing. |
| A selector that matches no element | No chat shows. The console says so. |
| Anything else | The chat floats. The console says so. |
When the element leaves the page and you do not set container again, no chat shows. Not even the bubble shows. The conversation goes on. The next configure({ container }) shows the chat again.
An element with no height shows no chat. Two seconds after the chat shows, the console says: Vendor chat: the chat's container has no height: give it one, for example height: 600px.
What the visitor sees
- The chat fills the element. It always shows. It has no bubble and no close button.
- The look's colours, type and shape apply. The skin keys
layout,bubbleandresponsivehave no effect. The open and close motion has no effect. - The conversation starts at the visitor's first action: a click in the message box, a starter, a message, or a click on a
data-knock-chatelement. To start it at page load, callknock.chat.open(). Then every visitor sees the welcome message. A returning visitor sees their conversation at once. - A click on a
data-knock-chatelement scrolls the chat into view and moves the focus to it.open()does not scroll the page and does not move the focus.close()does nothing.
React to the chat
Use it when: your page changes when the chat opens or closes, or your code logs the chat's errors.
knock.on() works before or after your Knock tag is ready. It returns a function that stops the listener.
import { knock } from '@knock-ai/sdk';
const offOpen = knock.on('chat:open', ({ test }) => {
document.documentElement.classList.add('chat-open');
if (!test) reportChatOpened(); // your own code, skipped in test mode
});
const offClose = knock.on('chat:close', () => {
document.documentElement.classList.remove('chat-open');
});
// Later, to stop listening:
offOpen();
offClose();In React, useKnockEvent() listens while the component is mounted:
'use client';
import { useState } from 'react';
import { useKnockEvent } from '@knock-ai/sdk/react';
export function ChatHint() {
const [chatOpen, setChatOpen] = useState(false);
useKnockEvent('chat:open', () => setChatOpen(true));
useKnockEvent('chat:close', () => setChatOpen(false));
return chatOpen ? null : <p>Questions? Ask us in the chat.</p>;
}| Event | Payload | When |
|---|---|---|
chat:open | { test } | The chat opened. For an inline chat: it shows in its element. |
chat:close | { test } | The chat closed. For an inline chat: it stopped showing. |
error | { message, cause } | Something failed. message says what (below). |
test is true while the chat runs in test mode. In test mode, cause.test is true too.
error message | What it means |
|---|---|
'chat failed to load' | The chat's code did not download. An ad blocker, your CSP or the network stopped it, or an open waited 15 seconds for it. It also fires when your Knock tag has no chat in its config and is from knock-tag 0.10.0 or earlier. The chat stays off until the page reloads. |
'chat failed to mount' | The chat's code downloaded but could not start on the page. |
'chat unavailable' | Knock refused the chat. cause.code says why: 'external-api.chat.origin-not-allowed', 'external-api.chat.not-found', 'chat-unavailable' or 'external-api.chat.captcha-invalid'. |
'chat could not start' | The conversation could not start. cause.status is the HTTP status. It is 0 when the request did not reach Knock. |
'message not sent' | A visitor message was not sent. The chat marks it "Not sent", with a Retry button. |
'chat session ended; the next message starts a new one' | The visitor's session is no longer valid. |
'booking page could not open' | Headless only: the booking page of an action did not open. |
Continue on Telegram or Slack adds no event. A tap on Telegram or Slack that fails fires no error. The one exception is a session that ended: then 'chat session ended; the next message starts a new one' fires.
To test your handlers, use createKnockMock() from @knock-ai/sdk/testing. It records the five chat calls. mock.emit('chat:open', { test: true }) fires your handlers. See Testing.
What the visitor sees
Only what your code changes. In the examples above, your page gets a chat-open class. The hint hides while the chat is open.
Draw your own UI
Use it when: your own UI draws the conversation, and Knock draws nothing.
Set headless in the same init({ chat }) call as in Set up the chat once, at app start, never in a later configure() call. Your function gets the conversation as a client, and your UI calls knock.chat.open() when it shows the chat. The rules, the types and complete examples are in Build your own chat UI.
Change the words and the language of "Continue on"
Use it when: your site is not in English, or you want other words for Continue on Telegram or Slack: its buttons, and what the chat says after a tap.
Pass strings and locale in chat in init(), or later with knock.chat.configure(). A change shows at once.
import { knock } from '@knock-ai/sdk';
import type { KnockChatOptions } from '@knock-ai/sdk';
knock.chat.configure({
locale: 'fr',
strings: {
continueCaption: 'Continuer dans vos applications',
continueOpening: 'Ouverture de {channel}…',
continueTapToOpen: 'Touchez pour ouvrir {channel}',
continueWaiting: 'On vous attend sur {channel}',
continuedNote: 'Poursuivie sur {channel}',
continueUnavailable: '{channel} n’est pas disponible pour le moment.',
continueFailed: 'Impossible d’ouvrir {channel}. Réessayez.',
},
} as KnockChatOptions); // @knock-ai/sdk 0.1.5 does not type strings and locale yet| Key | English default | Where it shows |
|---|---|---|
continueCaption | Continue in your own apps | The caption over the buttons |
continueLabel | {channel} | Each button |
continueOpening | Opening {channel}… | The new tab, until the app's page loads. Also after a click on the Slack icon in the header |
continueTapToOpen | Tap to open {channel} | The button when the browser blocked the tab, and the label of the Slack icon in the header then |
continueWaiting | Waiting for you on {channel} | Until the visitor arrives on the app |
continuedNote | Continued on {channel} | The label of the app's icon in the header, and the note after a tap opened an app's plain link. That note does not mean the chat continued |
continueUnavailable | {channel} isn’t available right now. | A tap on an app that Knock no longer offers |
continueFailed | Couldn’t open {channel}. Try again. | Any other tap that failed |
channelTelegram | Telegram | The app's name in {channel} |
channelSlack | Slack | The app's name in {channel} |
bookingUnavailable | That booking option is no longer available. | A booking button that is no longer offered |
bookingFailed | Couldn’t open the booking page. Try again. | A booking page that did not open |
{channel}is the app's name. The name is a key too:channelTelegramorchannelSlack.- Inside one source, a
<key>.<channel>key wins over<key>. For example,continueLabel.slacksets the Slack button only. Your page'scontinueLabelstill wins over acontinueLabel.slackin your Knock tag. - Each value is plain text. A label (
continueCaption,continueLabeland the app names) takes up to 40 characters. Any other text takes up to 120. - The chat never cuts a value. It skips a blank or longer value, and takes the text from the next source.
- The chat looks for each text in this order: your page's
strings, then the words in your Knock tag for the visitor's language, then English. In your tag, it looks for the exact language first and then its main language:pt-BR, thenpt. stringsis one flat record, with no languages in it. So pass the words for the visitor's language yourself. Knock can also put words for each language in your Knock tag: ask your Knock contact.- Only English is built in.
locale is the visitor's language, as a BCP 47 tag of up to 35 characters, such as fr or pt-BR. Without it, the chat uses the locale of your Knock tag, then your page's <html lang>, then the browser's language.
- The chat sends it to Knock with every tap, on a booking button too.
- It sets the language of the start-chat.com page that a tap opens: English, Spanish, French, Korean, Portuguese, Russian or Chinese. Any other language gets English.
- It sets the language of the recap's header, and of the "You:" and "Us:" labels of a recap that quotes the last exchange. These come in the same seven languages. Any other language gets English.
- It changes no other text of the chat, and not the direction of the text.
@knock-ai/sdk 0.1.5 does not type strings and locale. They work, but in an object literal TypeScript reports them as unknown keys. That is why the example casts the options to KnockChatOptions. In init(), the cast goes on the chat object:
knock.init({
tagId: 'YOUR_TAG_ID',
chat: {
magicLinkId: 'YOUR_MAGIC_LINK_ID',
locale: 'fr',
strings: { continueCaption: 'Continuer dans vos applications' },
} as KnockChatOptions,
});Remove the cast once your SDK version types them. Through knockq, chat.configure takes the same keys.
What the visitor sees
- The caption and the buttons in your words. Each button keeps the app's icon.
- After a tap, a new tab that says "Ouverture de Telegram…". Then the start-chat.com page in French.
- On the app, the recap's header in French.
Options at a glance
| Option | What it does | Values |
|---|---|---|
launcher | What opens the chat | 'both' (default), 'bubble', 'buttons' |
starters | Suggested first messages | Up to 4 strings, each up to 80 characters |
brandName | The name in the header and in the message box | A string, up to 60 characters |
agentName | The AI agent's name | A string, up to 60 characters. Without it: brandName |
agentImageUrl | The AI agent's picture | A URL or a path on your site. null clears it. |
magicLinkId | The magic link the chat runs on | The link's ID, not its URL. null goes back to your Knock tag's link. |
container | Shows the chat inside an element | An element, a CSS selector, or null for the floating chat |
headless | Your own UI draws the chat | A function. Set it in init(). |
test | Test mode | true, or a scenario name such as 'rep' or 'booking' |
strings | The words of Continue on Telegram or Slack and of a failed booking. They win over the words in your Knock tag | Key to plain text. See the words of "Continue on" |
locale | The visitor's language | A BCP 47 tag, such as 'fr'. Default: your tag's, then <html lang>, then the browser's |
skin.preset | The look | 'harbor', 'nightshift', 'fieldbook', 'signal', 'terminal', 'pixel' |
skin.mode | Light or dark | 'light', 'dark', 'auto' (the visitor's system setting) |
skin.colors, skin.colorsDark | Your colours, in light and in dark mode | Hex colours. colorsDark: null makes dark colours from brand. |
skin.bubble | The bubble's label, icon and size | Up to 24 characters, an icon name, 44 to 72 pixels |
skin.assets | Your pictures: bubble, header and wall | A URL or a path on your site. null clears it. |
skin.motion | The open and close motion: preset, curve, speed, webgl | See the morph transition |
open({ send }), data-knock-send | Sends a message for the visitor, once per conversation | A string |
open({ message }), data-knock-message | Pre-fills the message box | A string |
For setup, the requirements and what to do when the chat does not show, see Chat. Start with Set it up and If the chat does not show.