InputDock

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

  1. 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.
  2. 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.
  3. 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:

index.html
<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.

index.html
<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>
AttributeExampleWhat it does
data-inputdock-chatck_…Required. The chat’s public key from Chats → Settings. Marks the element the chat is drawn into.
data-themelight | dark | autoColour scheme.
data-accent#2563ebAccent colour. Overrides the theme colour set in the dashboard.
data-radius12Corner radius in pixels (0 to 32). Overrides the dashboard setting.
data-soundoffMute 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:

Chat.jsx
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.

app.js
// 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 - or 1., 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.

app.js
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:

response header
Content-Security-Policy:
  script-src  'self' https://cdn.inputdock.com;
  connect-src 'self' https://api.inputdock.com wss://chat.inputdock.com;

Troubleshooting

SymptomLikely cause and fix
Nothing appearsCheck 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 availableThe 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 appearThe 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 historyHistory is tied to the visitor’s browser storage. A different browser or device, or cleared site data, starts a new conversation.
429 Too many requestsA visitor can make 60 chat requests a minute, and a chat accepts 5,000 requests a day.