Skip to content
AI Support / Dev Center

10 results · Esc to close

Documentation/Widget SDK

GETTING STARTED

Widget SDK

Instalação, configuração e ciclo de vida do SDK 0.3.2.

Install a pinned version

Download the SDK and check its SHA-256. Serve the file on your domain or upload the versioned public URL. A single version must be uploaded per page.

HTML
<script src="https://support-ai.pontes.uk/widget.v0.3.2.js"></script>

Mount in the authenticated session

The callbacks below are from your application. They must use the current session, validate responses, and handle unavailability. Initialize only after authorized bootstrap.

JavaScript
// Depois de autenticar e revalidar a pessoa no seu backend.
// Estes callbacks são implementados pelo seu aplicativo.
const data = await fetchAuthenticatedBootstrap();
const widget = AISupportWidget.init({
  apiUrl: 'https://support-ai.pontes.uk',
  tenantKey: data.tenantKey,
  jwt: data.jwt,
  context: data.context,
  locale: data.locale,
  theme: 'light',
  position: 'bottom-right',
  onTokenRefresh: async () =>
    (await fetchAuthenticatedBootstrap()).jwt,
  onOpen: async () =>
    widget.updateContext(await fetchAuthorizedContext()),
});
// No logout, troca de pessoa/organização/papel e unmount:
// widget.destroy();

Configuration and methods

tenantKey, jwt, apiUrl and context make up the integration configuration. The context needs to accompany each new case.

Field / methodRole
theme / position / brandColorWidget theme, position, and color
onTokenRefreshReturn a new JWT for the same identity
onOpenUpdate context before opening
open() / close()Open/close interface
updateJwt(jwt)Update session for the same person
updateContext(context)Update context for the next case
destroy()Aborts requests and removes instance and local persistence

React, navigation, and PWA

Mount in useEffect with stable callbacks and identity as dependency. Execute destroy in cleanup and immediately on logout. Context and sessions should not enter the PWA cache or replay tools.

Shadow DOM isolates styles, but the CSP needs to allow loading and the style used by the SDK. Do not remove the entire policy to make it work.

CONTINUE HEREAPI Reference