Skip to main content
The chat widget puts one of your agents on your website. Visitors talk to the agent in a panel on the page. The conversation reaches your workspace like any other channel. You create the widget in the app, under Channels, as a website chat. It gets a public key that starts with pub_. The key is in your page source, so it is not a secret. The agent on the channel answers, and it must be published.

Add it with a script tag

Paste this before </body> on every page. The app shows the same snippet with your key filled in.
  • Replace VERSION with a version from https://cdn.impellabs.tech/sdk/versions.json. The current field names the latest one and supported lists the others. A pinned path never changes under your site.
  • Without data-api-base-url the widget runs its built-in demo and does not reach your agent.
  • Any option below can be a data- attribute in kebab case, for example data-start-open="true". Set data-auto="false" to stop the widget from starting itself, then call ImpelChat.init when you are ready.

Add it with npm

The package is @impellabs/chat-widget. Pin an exact version, because options can change between releases.
Importing the package does not start a widget. Only init does.

Allowed sites

When you create the widget you can list the sites that may use it, for example https://shop.example. Write each one as a scheme and host. With no list, the widget works on any site. With a list, a request from another site gets a 403 with a reason. The widget then greys its launcher, shows the message, and fires the blocked event.

Options

Set options in init, as data- attributes, or from the widget settings in the app. A value from the app wins over an attribute in an old snippet. A value you pass to init wins over the app. The settings you save in the app are sent to the widget by GET /api/v1/chat/status. That list excludes key, apiBaseUrl, transport, container, identify, zIndex, soundBase, cards and inline. Only your code sets those.

Control it from your page

Events are ready, open, close, message, reply, rating, fullscreen and blocked. An error inside your listener does not reach the widget. The widget stores the visitor’s thread in the browser under impel_chat_session and reads it back on the next page. It writes nothing until the visitor types. If storage is blocked, the widget still works and forgets the thread.

The public endpoints

The widget calls these routes under the apiBaseUrl. They need no token. Each carries X-Impel-Key and, after the first answer, X-Impel-Session. Browsers may call them from any site: the server answers cross-origin requests and checks the allowed sites itself. The server returns a signed visitor handle in X-Impel-Session. The widget sends it back on each call. A handle that the server did not sign starts a new thread.

Send a message

The body takes these fields.
  • text: up to 4000 characters. Send text, files, or both.
  • files: up to ten file links from /chat/upload.
  • collected: details the visitor typed, such as name, email and phone. Only those three reach the contact, and as claims.
  • page: an object that describes the page, for example its url.
  • tap: {"id": "..."} when the visitor taps a suggestion or a row the agent offered.
The reply is the agent’s own text, plus blocks and chips built from its messages. If no answer comes in time, reply holds the channel’s waiting words in the visitor’s language. A blank waiting message returns an empty reply.

Upload a file

POST /chat/upload takes a multipart form with one file field and returns {"url": "..."}. Put that link in the files list of the next message. A file can be up to 20 MB. The server checks the file type and refuses a file that is not what its name says. Links to files last 90 days.

Errors

  • Channels lists the channel routes, including how to create the widget.
  • Conversations shows how to read and answer the thread from your own tools.