Skip to Content

SDK

The NXTL SDK makes it easy to deliver personalized experiences in any website or web app. It handles signal management, stable DOM references, artifact detection and consumption, and provides a simple, high-level interface to the NXTL API.

Installation

Install npm package:

npm install nxtl

Or use the CDN:

<script type="module"> import NXTL from "https://cdn.nxtl.ai/nxtl.es.js"; </script>

Initializing the client

import NXTL from nxtl; const nxtl = await new NXTL({ apiKey: "YOUR_API_KEY", projectId: "YOUR_PROJECT_ID", });

With CDN:

import NXTL from "https://cdn.nxtl.ai/nxtl.es.js"; const nxtl = await new NXTL({ apiKey: "YOUR_API_KEY", projectId: "YOUR_PROJECT_ID", });

Signal management

NXTL signals need to be captured and stored in order to preserve user context and personalization state.

The SDK provides a reference implementation for NXTL signal management, representing signals as a stack data structure maintained on the NXTL instance.

Persistence is handled via a secure nxtl_signal cookie, which maintains signal state across sessions (cookie consent is requested from the user before storing any data).

Stable DOM references

NXTL allows any frontend framework to deliver personalized experiences by relying on deterministic data-nxtl-ref attributes that remain stable across renders. The SDK implements creation of such attributes.

The registerMatrix method traverses the DOM and determines the attributes, then feed these to NXTL, thus enabling NXTL to generate and maintain the necessary matrix.

Artifact detection and consumption

Stable DOM references are what makes artifact consumption possible when certain query parameters are detected, allowing NXTL to reliably update elements. The SDK implements automatic detection and consumption of artifacts.

Key methods

MethodWhat it does
nxtl.callProcesses context parameters to generate an assistant message and suggestions, retrieve relevant entries, and assess optimal user journey and matrix.
nxtl.registerMatrixRegisters a matrix for the current location path, enabling NXTL to recognize and manage it.
nxtl.signalPushAdds a signal to the top of the signal stack.
nxtl.signalPopRemoves a signal from the top of the signal stack.

Last updated on