Skip to main content
The embed snippet adds window.replyful to your page. It works the same for every layout: floating bubble, side panel, full page and search bar.

Calling the API

There are two ways to call a command:
The call form works everywhere and at any time. Calls made before the chat has loaded are queued and run in order once it has. The method form works once the chat has loaded. Before that it works only with the website snippet: the Google Tag Manager snippet supports just the call form until the chat has loaded. If you’re unsure which snippet a page uses, use the call form.

Return values

Once the chat has loaded, every command returns a Promise. Before that, queued calls return undefined, so don’t rely on a return value in code that may run early. To run code as soon as the chat is ready, listen for ready; it fires straight away if the chat is already ready:
Expected outcomes, such as a token that fails verification, resolve as values. A Promise rejects only when the call itself is wrong, such as an unknown command or a missing argument.

Commands

The chat window loads on demand. With the chat bubble or side panel, that happens when the visitor first hovers over or opens the chat button. identify and newConversation resolve once it has loaded, so call them early but don’t hold up your own page logic waiting for them. In state(), available is false when the chat can’t run on this page (see the unavailable event), layout is floating, panel, page or search, and identified is true once identify has succeeded.

Events

Each callback receives one plain detail object. An error thrown in your callback doesn’t affect the chat or other callbacks. ready and unavailable are sticky: a callback added after they fired runs straight away.
  • reason on open and close is what caused it: api (your code), launcher (the chat button), escape, backdrop, close-button, or navigation (the visitor moved to a page where the chat is hidden).
  • reason on unavailable is domain-not-allowed (the page’s domain isn’t in the chatbot’s allowed domains), channel-unavailable (the chatbot is turned off or deleted) or network.
  • transferred is present when the visitor’s earlier anonymous chat moved to the signed-in user: { conversations, messages }, as counts.
  • Message events carry no message text.

Examples

Open the chat from your own button

Single-page apps and React

Subscribe when your component mounts and remove the same callback when it unmounts. off also works on calls queued before the chat has loaded. Your component can mount before the snippet has run, for example when Google Tag Manager adds the snippet later. If window.replyful doesn’t exist yet, wait for the replyful:load event on window before subscribing. The chat can’t fire events before then, so you won’t miss any. Don’t define window.replyful yourself: the snippet replaces it, and any calls you queued on it would be lost.
The snippet is safe to run more than once, so it doesn’t matter if your app or Google Tag Manager runs it again after a client-side navigation.

Identify a signed-in user

See User identification for how to sign the token.

Send chat activity to your analytics