byeego
v0.1.2
Published
Official Byeego SDK — embed the Byeego AI assistant into any website or app, with a typed browser loader, React bindings, and a Node client for the Developer API.
Maintainers
Readme
@byeego/sdk
Official Byeego SDK. Embed the Byeego AI assistant into any website or app with a typed browser loader, React bindings, and a Node client for the Developer API.
This package is a thin, typed wrapper. The assistant runtime is served from
the Byeego backend (/api/sdk.js), so the package stays a few KB and never goes
stale — you always get the latest assistant behaviour without bumping a version.
npm install @byeego/sdk
# or: pnpm add @byeego/sdk / yarn add @byeego/sdkThree entry points:
| Import | Use it for |
| --- | --- |
| @byeego/sdk | Framework-agnostic browser loader + typed window.Byeego API |
| @byeego/sdk/react | <ByeegoWidget /> component and useByeego() hook |
| @byeego/sdk/server | Typed Node client for the /v1 Developer API (server-side) |
1. Browser (any framework or plain JS)
import { initByeego } from "@byeego/sdk";
const { api } = await initByeego({
installKey: "bgo_app_xxx", // public environment install key
});
api.open(); // open the chat panel
await api.ask("How do refunds work?");
api.track("checkout_started", { plan: "pro" }, "workflow");Headless (use your own UI, no floating launcher):
const { api } = await initByeego({ installKey: "bgo_app_xxx", widget: false });
const answer = await api.ask("What are your hours?");Origin
By default the loader fetches the SDK from https://widget.byeego.com. Override
it for local development or a custom widget domain:
await initByeego({ installKey: "bgo_app_xxx", origin: "http://localhost:3002" });2. React / Next.js / Remix
import { ByeegoWidget } from "@byeego/sdk/react";
export default function App() {
return (
<>
{/* your app */}
<ByeegoWidget installKey="bgo_app_xxx" />
</>
);
}The component renders nothing itself (the launcher + iframe are injected by the
runtime), is SSR-safe, and closes the panel on unmount. In Next.js App Router,
render it from a Client Component ("use client").
Imperative control with the hook:
import { useByeego } from "@byeego/sdk/react";
function SupportButton() {
const { api, loading } = useByeego({ installKey: "bgo_app_xxx", widget: false });
return (
<button disabled={loading} onClick={() => api?.openSupport()}>
Need help?
</button>
);
}react is an optional peer dependency — it's only required if you import from
@byeego/sdk/react.
3. Server-to-server (Node)
Manage bots, conversations, app installs, leads, and webhooks from your backend with a typed client. Keep the API key server-side only.
import { ByeegoServerClient, ByeegoApiError } from "@byeego/sdk/server";
const byeego = new ByeegoServerClient({
apiKey: process.env.BYEEGO_API_KEY!, // bgo_live_... or bgo_test_...
});
try {
const { bots } = await byeego.get<{ bots: unknown[] }>("/bots");
const created = await byeego.post("/conversations", { bot_id: "bot_123" });
} catch (err) {
if (err instanceof ByeegoApiError) {
console.error(err.code, err.status, err.requestId);
}
}Reseller keys must scope each call to a managed client. Set it once:
const byeego = new ByeegoServerClient({
apiKey: process.env.BYEEGO_RESELLER_KEY!,
clientId: 4021,
});Base URL defaults to https://connect.byeego.com. For local dev:
new ByeegoServerClient({ apiKey: "bgo_test_...", baseUrl: "http://localhost:3000" });Browser API reference
initByeego() / loadByeego() resolve the window.Byeego object:
| Method | Description |
| --- | --- |
| init(options) | Load config, start a session, mount the widget |
| identify(identity) | Start a session for a known/signed visitor |
| track(name, props?, type?) | Track a product event |
| setContext(context) | Update page/screen/feature context |
| open() / close() / toggle() | Control the chat panel |
| openSupport() / openGuide() / openOnboarding() | Track + open in a mode |
| sendMessage(text) | Send a message, get { conversationId, answer } |
| ask(text) | Send a message, resolve just the answer string |
| config() / session() | Read current config / session |
Development
npm install
npm run build # emits dist/ with .js + .d.ts for all three entry points
npm run typecheckLicense
MIT
