Skip to main content
window.PaperlinkAIChat.init mounts the widget and returns an instance. Use the instance to open or close the widget from your own buttons. Use it also to clean up in a single-page app.
The script tag with data-api-key starts the widget for you. It stores the instance on window.PaperlinkAIChatInstance. For the types, see TypeScript types.

Methods

void
Opens the widget panel. In inline mode, this method does nothing, because the panel is always visible.
void
Closes the widget panel. In inline mode, this method does nothing.
void
Clears the stored session of the visitor in the browser. The visitor then starts a new conversation.
void
Stops the widget and removes it from the page. Call it when your page or component unmounts.

Example: open the widget from your own button

Add a button to your page. Call open() when a visitor selects it.
The widget script loads with async, so read the global inside the handler. If you start the widget from your code, keep the instance that init returns. window.PaperlinkAIChatInstance holds only the widget that the tag starts.
The instance has only the four methods above. These features do not exist: toggle, sendMessage, identify and an event emitter with on and off. To react to widget activity, use the onAnalyticsEvent option.

Analytics events

See the events that the widget reports to your own analytics.