Skip to main content
To embed the webchat in a guest-facing web app (e.g. a PWA or a web view embedded in an app), use the Webchat SDK. It provides the full widget behavior and programmatic control through methods and events.

Prerequisites

  • The Client ID of your app. You find it in the DialogShift dashboard. For development and testing you can use the demo Client ID pro12bd.
  • The channel code of the source. For a guest app it must be set to exactly pwa-guestapp. The channel code lets us attribute conversations to the correct source.
The channel code cannot be chosen freely. For a guest app, set it to exactly pwa-guestapp. Additional channel codes only in coordination with DialogShift Support.

Integration via SDK

The SDK renders the toggle button and the chat window, loads the chat inside an iframe, and exposes methods to control it. It is available as a UMD and ES2015 bundle.
1

Install the SDK

2

Initialize the chat

Set your Client ID as id and the channel code through context.channel. The example uses the demo Client ID pro12bd.
Dialogshift.instance() returns a singleton: calling it again without arguments returns the same instance.

Key options

Full-screen integration: chat only

The most common case in a guest app: the screen should show only the chat, without a floating button. To do this, skip rendering the button and open the chat window immediately.
With initialElement the specified element is triggered automatically on open - the guest immediately sees a welcome message.

Lifecycle: init and ready

The SDK fires two central events:
  • init fires once the widgets are rendered and the configuration is loaded. From now on you can call API methods, but you cannot trigger messages yet.
  • ready fires once the chat is connected to the messaging channel. The connection is only established when the chat window is opened for the first time - if it stays closed, ready never fires.

Controlling at runtime

More methods and events

The SDK also offers methods for teasers, button text, unread counters, and themes, as well as events for sent and received messages. You find the full API reference in the Webchat SDK GitHub README; the SDK demo shows the widget behavior live.