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
VERSIONwith a version fromhttps://cdn.impellabs.tech/sdk/versions.json. Thecurrentfield names the latest one andsupportedlists the others. A pinned path never changes under your site. - Without
data-api-base-urlthe widget runs its built-in demo and does not reach your agent. - Any option below can be a
data-attribute in kebab case, for exampledata-start-open="true". Setdata-auto="false"to stop the widget from starting itself, then callImpelChat.initwhen you are ready.
Add it with npm
The package is@impellabs/chat-widget. Pin an exact version, because options can change between releases.
init does.
Allowed sites
When you create the widget you can list the sites that may use it, for examplehttps://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 ininit, 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
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 theapiBaseUrl. 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
text: up to 4000 characters. Sendtext,files, or both.files: up to ten file links from/chat/upload.collected: details the visitor typed, such asname,emailandphone. Only those three reach the contact, and as claims.page: an object that describes the page, for example itsurl.tap:{"id": "..."}when the visitor taps a suggestion or a row the agent offered.
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
Related
- Channels lists the channel routes, including how to create the widget.
- Conversations shows how to read and answer the thread from your own tools.