Chat integration
Add live chat to your website
Live chat uses its own script and its own public key, separate from forms. Embedding a form instead? See the Form integration guide.
Live in three steps
- Set it up. In your dashboard, open Chats, then Settings. Give the chat a title, pick which details to ask visitors for (name, phone, email), choose its colour and how round the corners are, and list the websites that may show it. Then save.
- Paste two lines. Copy the Embed code, with your public key (
ck_…) already filled in, to the place on your page where the chat should appear. - Reply from the dashboard. Visitors write, you answer from Conversations. Every message in both directions is stored with the conversation.
Basic embed
Put the div where the chat should appear and the script anywhere after it:
<div data-inputdock-chat="ck_your_public_key"></div>
<script src="https://cdn.inputdock.com/v1/chat.js" async></script>Options
Everything except the key is optional. The dashboard settings apply unless an attribute on the page overrides them.
<div
data-inputdock-chat="ck_your_public_key"
data-theme="auto"
data-accent="#2563eb"
data-radius="12"
data-sound="off"
></div>
<script src="https://cdn.inputdock.com/v1/chat.js" async></script>| Attribute | Example | What it does |
|---|---|---|
data-inputdock-chat | ck_… | Required. The chat’s public key from Chats → Settings. Marks the element the chat is drawn into. |
data-theme | light | dark | auto | Colour scheme. |
data-accent | #2563eb | Accent colour. Overrides the theme colour set in the dashboard. |
data-radius | 12 | Corner radius in pixels (0 to 32). Overrides the dashboard setting. |
data-sound | off | Mute the sound for incoming replies. |
What the chat asks the visitor (name, phone, email: off, optional or required), its title and its default colour and radius are set in the dashboard, not on the page.
Frameworks and site builders
In plain HTML, WordPress, Webflow, Shopify, Astro and other server-rendered pages, paste the two lines from Basic embed into a custom HTML block or your template. In React and Next.js, load the script once and mount into a ref:
import { useEffect, useRef } from 'react'
export default function Chat() {
const ref = useRef(null)
useEffect(() => {
const script = document.createElement('script')
script.src = 'https://cdn.inputdock.com/v1/chat.js'
script.async = true
script.onload = () => window.InputDockChat?.mount(ref.current, { key: 'ck_your_public_key' })
// The script may already be on the page from an earlier visit.
if (window.InputDockChat) script.onload()
else document.body.append(script)
}, [])
return <div ref={ref} />
}Single-page apps, modals and tabs
The script exposes window.InputDockChat with mount(element, options) and mountAll(). Options use the same names as the attributes without data-, plus key. An element is only mounted once.
// Mount into any element, any time (route change, modal open…)
InputDockChat.mount(document.querySelector('#support-chat'), {
key: 'ck_your_public_key',
accent: '#2563eb',
})
// Or pick up every <div data-inputdock-chat> that was added later
InputDockChat.mountAll()What visitors and you see
- The visitor is asked for the details you require once, with their first message. After that the chat header shows what they gave.
- Every message in both directions is stored. When a visitor comes back in the same browser, their history is loaded and they can scroll back through older messages.
- Messages can use
*bold*,_italic_,++underline++,~strikethrough~, lists that start with-or1., and web addresses become links. A message can be up to 2,000 characters. - You answer from Chats → Conversations in the dashboard. Platform admins can read conversations but never send.
Events
The chat reports load and connection problems as an event that bubbles up from the element you placed: inputdock:error, with detail.status and detail.message.
document.addEventListener('inputdock:error', (event) => {
console.warn('Chat failed', event.detail.status, event.detail.message)
})Allowed websites
By default a chat key works from any website. To limit it, list one origin per line under Allowed websites in Chats → Settings, for example https://www.example.com or https://*.example.com. Rotating the public key makes pages with the old embed code stop working until you paste the new one.
Content Security Policy
If your site sends a CSP header, allow the script origin, the API and the live connection:
Content-Security-Policy:
script-src 'self' https://cdn.inputdock.com;
connect-src 'self' https://api.inputdock.com wss://chat.inputdock.com;Troubleshooting
| Symptom | Likely cause and fix |
|---|---|
| Nothing appears | Check the key starts with ck_ and the chat is still enabled for your client. Chat keys (ck_…) are different from form keys (pk_…). Open the browser console for an inputdock:error. |
| The chat says it is not available | The page’s website is not in Allowed websites, or the key was rotated and the page still has the old embed code. |
| Messages send but replies are slow to appear | The live connection could not open (a firewall or CSP is blocking it). Messages still go through and arrive on the next check; allow the chat socket in connect-src. |
| Visitors lose their history | History is tied to the visitor’s browser storage. A different browser or device, or cleared site data, starts a new conversation. |
| 429 Too many requests | A visitor can make 60 chat requests a minute, and a chat accepts 5,000 requests a day. |