JavaScript SDK
The framework-agnostic core SDK — mount the embeddable talking-agent widget, or call the headless ask API, from any web page. No framework required. React and Vue apps should generally prefer @avatar-platform/react or @avatar-platform/vue instead, which wrap this package.
Installation
npm install @avatar-platform/js
# or
yarn add @avatar-platform/js
# or
pnpm add @avatar-platform/js
This is the same underlying package the React and Vue SDKs wrap, and mounts the real embed-loader.js script — the one behind the plain <script data-bot> snippet on your dashboard's Install code step. No bundler configuration is needed.
mountAvatarWidget(options)
Mounts the same floating chat widget you'd get from the <script data-bot> snippet on your dashboard's Install code step.
import { mountAvatarWidget } from '@avatar-platform/js';
mountAvatarWidget({
serverUrl: 'https://your-deployment.com',
botId: 'YOUR_BOT_ID',
});
Call this once, typically as early as possible in your app's lifecycle (e.g. your root layout or entry file). It's safe to call more than once with the same botId — later calls are a no-op.
There's no unmount() — the underlying embed script doesn't support teardown, so the widget is meant to persist for the page's lifetime, the same way a support-chat widget script normally would.
mountAvatarWidget options
| Option | Type | Default | Description |
|---|---|---|---|
| serverUrl | string | — | Required. Base URL of your Talkmoji deployment, no trailing slash. |
| botId | string | — | Required. The public ID of your project. Find it in the dashboard → Install code step. |
There's no position/theme/open()/close() option here either — those are configured per-project in your Talkmoji dashboard's Widget settings, not overridable per-mount.
askAvatar(options)
Headless Q&A — send a question, get a text answer with source citations back. No widget UI involved.
import { askAvatar } from '@avatar-platform/js';
const result = await askAvatar({
serverUrl: 'https://your-deployment.com',
botId: 'YOUR_BOT_ID',
question: 'What payment methods do you accept?',
});
console.log(result.answer); // string
console.log(result.sources); // { title, url, snippet }[]
console.log(result.sessionId); // pass this back in to continue the same conversation
This calls POST /embed/:publicId/ask over HTTPS — no widget, no voice, no Rive.
askAvatar options
| Option | Type | Default | Description |
|---|---|---|---|
| serverUrl | string | — | Required. |
| botId | string | — | Required. |
| question | string | — | Required. |
| sessionId | string | — | Optional — continue an existing conversation instead of starting a new one. |
TypeScript types
Type declarations are included — no @types package needed.
import type {
MountAvatarWidgetOptions,
AskAvatarOptions,
AskAvatarResult,
AskAvatarSource,
} from '@avatar-platform/js';
interface AskAvatarResult {
answer: string;
sources: AskAvatarSource[];
sessionId: string;
}
interface AskAvatarSource {
title: string;
url: string | null;
snippet: string;
}
Plain HTML / no bundler
If your page has no build step at all, skip the npm package and use the script-tag embed instead — it's the same widget, delivered without an import:
<script
src="https://your-deployment.com/lipsync-sdk.js"
data-public-id="YOUR_BOT_ID"
data-position="bottom-right"
data-theme="#6366f1"
data-size="md"
></script>