@nsupp/chatbox-sdk
v0.1.0
Published
Typed web SDK for the nsupp chatbox — configure, open/close, identify visitors, track events. Dependency-free.
Maintainers
Readme
@nsupp/chatbox-sdk
Typed web SDK for the nsupp chatbox. A thin, dependency-free wrapper over the on-page $posthubify command
queue served by /widget/embed.js. Configure once, then open the chatbox, identify visitors, and track events —
all fully typed.
Install
npm install @nsupp/chatbox-sdkQuickstart
import Nsupp from '@nsupp/chatbox-sdk';
// Inject the chatbox and set your website public key (once, as early as possible).
Nsupp.configure('YOUR_WEBSITE_PUBLIC_KEY');
// Control the chatbox.
Nsupp.chat.open();
Nsupp.chat.toggle();
// Identify the visitor.
Nsupp.user.setEmail('[email protected]');
Nsupp.user.setData({ name: 'Jane', plan: 'pro' });
// Track a custom event (drives campaigns & message triggers).
Nsupp.event.track('checkout_started');
// Run a message trigger by id.
Nsupp.trigger.run('pricing-help');Named imports work too:
import { configure, chat, user, event } from '@nsupp/chatbox-sdk';
configure('YOUR_WEBSITE_PUBLIC_KEY');
chat.open();Identity Verification
When Identity Verification is enabled on your workspace, pass a server-computed signature alongside the email.
Never compute the signature in the browser.
Nsupp.user.setData({
email: '[email protected]',
name: 'Jane',
signature: '<hmac-from-your-server>',
});API
| Call | Description |
| --- | --- |
| Nsupp.configure(publicKey, { apiBase?, autoload? }) | Set the website public key and inject the embed script. |
| Nsupp.chat.open() / close() / toggle() | Control chatbox visibility. |
| Nsupp.user.setEmail(email) | Bind the visitor to an email. |
| Nsupp.user.setData({ email?, name?, signature?, ...attrs }) | Bind identity + custom attributes. |
| Nsupp.event.track(name) | Report a custom event. |
| Nsupp.trigger.run(id) | Run a message trigger. |
| Nsupp.identify(data) | Convenience alias for user.setData. |
Options
apiBase— API origin serving the widget bundle. Defaults tohttps://api.nsupp.com.autoload— Inject the embed<script>automatically (defaulttrue). Setfalseif you loadembed.jsyourself.
SSR
All calls are safe to invoke in a non-browser environment: outside the browser they are no-ops, so you can call the SDK from isomorphic code without guards.
Native SDKs
iOS (Swift) and Android (Kotlin) native SDKs are shipped — see packages/ios-sdk and
packages/android-sdk, or the iOS SDK and
Android SDK guides. They talk to the same
endpoints as this package, so a conversation started on your website continues in your app.
A React Native SDK does not exist yet.
License
UNLICENSED — © nsupp.
License
Licensed under the Apache License 2.0.
"nsupp" and the nsupp logo are trademarks of Asindie, Inc. The license grants no trademark rights — see the trademark policy for what use is permitted.
