@getnexorai/sdk provides two separate surfaces:
- a server-side JavaScript client for 16 public REST operations;
- an advanced browser widget for Web Chat.
@getnexorai/sdk v0.1.44. It does not claim to wrap the complete REST API.
Install for server use
The SDK requires Node.js 18 or later.@getnexorai/sdk/chat.
Server quick start
SetNEXOR_API_KEY in your server’s secret store. Do not commit it.
createLead and createLeadsBulk always send skip_first_message: true. Creating a lead through these helpers does not, by itself, mean the Agent immediately sends its ordinary first cadence message.
For dependency injection or multi-tenant server code, create independent clients instead of changing the singleton:
REST methods
All 16 methods below are available on the initialized default export and onNexorClient.
Use the REST API reference for endpoints the SDK does not wrap.
HTTP behavior
Set
maxRetries: 0 for a non-idempotent operation when repeating it could duplicate an effect. Passing idempotencyKey adds an Idempotency-Key header; it does not, on its own, guarantee that every endpoint deduplicates the request.
Handle errors
The SDK exportsNexorError, NexorAPIError, NexorAuthError, NexorValidationError, and NexorNetworkError.
nexor-sdk-js/0.1.0 in its Node.js User-Agent. Do not use that header value to determine the installed package version.
Browser widget
For most websites, use the smaller hosted Web Chat loader. It does not require npm and its snippet comes directly from the Agent’s Install section. Use the SDK widget when you need programmatic control throughinitChat, callbacks, or runtime configuration. The IIFE build exposes a global named Nexor.
Callbacks and widget handle
Pass callbacks toinitChat when the host page needs lifecycle or conversation events.
initChat returns a handle with these methods:
send(text) resolves after the message is queued, not after Nexor returns or paints the reply. Use onMessage to observe the later bot message and onError to observe a failed turn.Widget request flow
The widget’s current network flow is not the older/api/public/chat path documented in previous SDK notes.
The two configuration routes are alternatives:
initChat chooses the public route at top level and the widget-scoped route in an iframe. Before visitor persistence or a chat turn, it requests a fresh proof-of-work challenge and, when one is available and solved, attaches the result. The configuration, proof-of-work, turn, pending, visitor, and telemetry routes are the normal widget transport and have route-specific request and session controls. Use the widget instead of calling them directly. The requestContact row is excluded from that assurance.
Reproduce the offline browser smoke
The repository smoke rebuildsdist/nexor.iife.js from the pinned SDK checkout, records its SHA-256 digest, and evaluates it in an empty JSDOM page. It replaces fetch with a closed mock that rejects every unrecognized origin or route, then verifies the global export, mounted DOM, top-level configuration request, proof of work when available, POST /api/widget/v1/turn, telemetry, and rendered reply. It also checks, without exercising the conditional flows, that both language pages list the embedded configuration, pending mailbox, visitor persistence, and public contact-request routes, and that the unsupported requestContact path carries the required warning.
Prepare the pinned SDK worktree once, then run the smoke without Nexor credentials or network calls: