CHATBOT

Chatbot SDK (@startupcore/api-client)

Browser-safe and server/BFF patterns for custom UIs.

When to use

  • SDK — custom app UI with your own message list, or a BFF that proxies widget APIs.
  • Widget script / React — fastest user-facing UI with no custom chat UI.
  • REST API — non-JavaScript backends.

Browser — anonymous session

ts

import startupCore from "@startupcore/api-client"; const session = await startupCore.widget.createAnonymousSession({ publicKey: "pk_live_xxx", botId: "bot_123", }); const response = await startupCore.widget.sendMessage("bot_123", { sessionToken: session.sessionToken, message: "What plans do you offer?", });

Server / BFF — authenticated session

ts

const session = await startupCore.widget.createAuthenticatedSession( { tenantId, workspaceId, environmentId, botId, externalUserId: user.id, email: user.email, authProvider: "custom", scopes: ["chatbot:private_action"], }, { serverApiKey: { keyId: process.env.STARTUPCORE_API_KEY_ID!, secret: process.env.STARTUPCORE_API_SECRET!, }, }, );