{"_id":"@alenta/chat-widget","name":"@alenta/chat-widget","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@alenta/chat-widget","version":"0.1.0","description":"Official Alenta AI chat widget SDK — typed React and vanilla JS wrappers around the Alenta loader.","license":"MIT","author":{"name":"Alenta AI"},"homepage":"https://alenta.ai","repository":{"type":"git","url":"git+https://github.com/hussainatalenta/alenta.git","directory":"packages/chat-widget"},"bugs":{"url":"https://github.com/hussainatalenta/alenta/issues"},"keywords":["alenta","chat","ai","widget","chatbot","embed","react","sdk"],"main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","sideEffects":false,"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./react":{"types":"./dist/react.d.ts","import":"./dist/react.js","require":"./dist/react.cjs"},"./vanilla":{"types":"./dist/vanilla.d.ts","import":"./dist/vanilla.js","require":"./dist/vanilla.cjs"}},"scripts":{"build":"tsup","typecheck":"tsc --noEmit","test":"vitest run","test:watch":"vitest","prepublishOnly":"npm run typecheck && npm run test && npm run build"},"peerDependencies":{"react":">=18","react-dom":">=18"},"peerDependenciesMeta":{"react":{"optional":true},"react-dom":{"optional":true}},"devDependencies":{"@testing-library/react":"^16.1.0","@types/react":"^19.0.1","@types/react-dom":"^19.0.1","jsdom":"^25.0.1","react":"^19.0.0","react-dom":"^19.0.0","tsup":"^8.3.5","typescript":"^5.7.2","vitest":"^2.1.8"},"publishConfig":{"access":"public"},"engines":{"node":">=18"},"gitHead":"5b59d12509ba03ec1577dc3200ea2cd0ae4ffecd","_id":"@alenta/chat-widget@0.1.0","_nodeVersion":"22.19.0","_npmVersion":"11.6.2","dist":{"integrity":"sha512-MP1fWGPqbaY4355OdOBNMoeYOGHsEaD7RnaMGHW3Clc625R/M/uy0qPY/FMqMAbjl/cVFZvDA7jzFAprLhdWvQ==","shasum":"8d84e2be50c5598a3e70c09acd8b1f2464544ba8","tarball":"https://registry.npmjs.org/@alenta/chat-widget/-/chat-widget-0.1.0.tgz","fileCount":22,"unpackedSize":165418,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDAaap2e9GFq/LkNKDK3ykfqiHr72WqcZvxrNKcMLjnmAIhAOqaeO7/kR/K2KEPtted8Ua4iQeL5Qw1vZT3MvxBFlJA"}]},"_npmUser":{"name":"alentainc","email":"info@alenta.ai"},"directories":{},"maintainers":[{"name":"alentainc","email":"info@alenta.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/chat-widget_0.1.0_1776918349527_0.9000888967190357"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-23T04:25:49.382Z","0.1.0":"2026-04-23T04:25:49.685Z","modified":"2026-04-23T04:25:49.987Z"},"maintainers":[{"name":"alentainc","email":"info@alenta.ai"}],"description":"Official Alenta AI chat widget SDK — typed React and vanilla JS wrappers around the Alenta loader.","homepage":"https://alenta.ai","keywords":["alenta","chat","ai","widget","chatbot","embed","react","sdk"],"repository":{"type":"git","url":"git+https://github.com/hussainatalenta/alenta.git","directory":"packages/chat-widget"},"author":{"name":"Alenta AI"},"bugs":{"url":"https://github.com/hussainatalenta/alenta/issues"},"license":"MIT","readme":"# @alenta/chat-widget\n\nOfficial SDK for embedding the [Alenta](https://alenta.ai) AI chat widget in any modern web app — typed React and vanilla JS wrappers around the Alenta loader.\n\n## Install\n\n```bash\nnpm install @alenta/chat-widget\n# or\npnpm add @alenta/chat-widget\n# or\nyarn add @alenta/chat-widget\n```\n\nYou'll need an **agent ID** (a UUID v4). Get one free at [alenta.ai/dashboard](https://alenta.ai/dashboard).\n\n## React\n\n```tsx\nimport { AlentaChat } from \"@alenta/chat-widget\";\n\nexport default function App() {\n  return (\n    <>\n      <main>{/* your app */}</main>\n      <AlentaChat\n        config={{ agentId: \"YOUR-AGENT-UUID\" }}\n        onLeadCaptured={(lead) => console.log(\"lead:\", lead)}\n      />\n    </>\n  );\n}\n```\n\n### Hook variant\n\n```tsx\nimport { useAlenta } from \"@alenta/chat-widget\";\n\nfunction ChatButton() {\n  const { instance, ready } = useAlenta({ agentId: \"YOUR-AGENT-UUID\" });\n  return (\n    <button disabled={!ready} onClick={() => instance?.open()}>\n      Talk to us\n    </button>\n  );\n}\n```\n\n`<AlentaChat />` and `useAlenta` both mount inside `useEffect`, so they're safe under SSR (Next.js App Router, Remix, etc).\n\n## Vue 3\n\n```vue\n<script setup lang=\"ts\">\nimport { onMounted, onBeforeUnmount } from \"vue\";\nimport { mount, type AlentaInstance } from \"@alenta/chat-widget/vanilla\";\n\nlet instance: AlentaInstance | null = null;\nonMounted(() => {\n  instance = mount({ agentId: \"YOUR-AGENT-UUID\" });\n});\nonBeforeUnmount(() => instance?.destroy());\n</script>\n```\n\n## Svelte\n\n```svelte\n<script lang=\"ts\">\n  import { onMount } from \"svelte\";\n  import { mount, type AlentaInstance } from \"@alenta/chat-widget/vanilla\";\n\n  let instance: AlentaInstance;\n  onMount(() => {\n    instance = mount({ agentId: \"YOUR-AGENT-UUID\" });\n    return () => instance.destroy();\n  });\n</script>\n```\n\n## Vanilla JS\n\n```html\n<script type=\"module\">\n  import { mount } from \"https://esm.sh/@alenta/chat-widget/vanilla\";\n\n  const chat = mount({\n    agentId: \"YOUR-AGENT-UUID\",\n    mode: \"bubble\",\n    position: \"bottom-right\",\n    primaryColor: \"#6366f1\",\n  });\n\n  chat.on(\"lead-captured\", (lead) => {\n    fetch(\"/api/leads\", { method: \"POST\", body: JSON.stringify(lead) });\n  });\n</script>\n```\n\n## Configuration\n\n| Option           | Type                        | Default            | Description                                       |\n| ---------------- | --------------------------- | ------------------ | ------------------------------------------------- |\n| `agentId`        | `string` (UUID v4)          | — **(required)**   | Your Alenta agent ID.                             |\n| `mode`           | `\"bubble\" \\| \"inline\"`      | `\"bubble\"`         | Floating launcher or inline panel.                |\n| `position`       | `\"bottom-right\" \\| \"bottom-left\"` | `\"bottom-right\"` | Launcher corner (bubble mode).                |\n| `target`         | `string \\| HTMLElement`     | —                  | CSS selector / element for inline mode.           |\n| `primaryColor`   | `string`                    | —                  | CSS color for branding.                           |\n| `launcherLabel`  | `string`                    | agent default      | Text on the launcher button.                      |\n| `openOnLoad`     | `boolean`                   | `false`            | Auto-open on first page load.                     |\n| `baseUrl`        | `string`                    | `\"https://alenta.ai\"` | Override for self-hosted or staging.           |\n| `debug`          | `boolean`                   | `false`            | Emit verbose console logs.                        |\n\n## Instance API\n\n`mount()` (and the `instance` returned by `useAlenta`) exposes:\n\n```ts\ninterface AlentaInstance {\n  open(): void;\n  close(): void;\n  toggle(): void;\n  sendMessage(message: string): void;\n  updateConfig(partial: Partial<AlentaConfig>): void;\n  destroy(): void;\n  isReady(): boolean;\n  on(event: AlentaEventName, handler: (data?: unknown) => void): () => void;\n}\n```\n\nAll methods are safe to call before the loader has booted — calls buffer and flush on ready.\n\n## Events\n\n| Event             | Payload shape (subject to change)                         |\n| ----------------- | --------------------------------------------------------- |\n| `widget-opened`   | `undefined`                                               |\n| `widget-closed`   | `undefined`                                               |\n| `message-sent`    | `{ text: string; role: \"user\" \\| \"assistant\" }`           |\n| `lead-captured`   | `{ name?: string; email?: string; phone?: string; ... }`  |\n\n```ts\nconst off = chat.on(\"lead-captured\", (lead) => { /* ... */ });\n// later\noff();\n```\n\n`on()` only forwards messages whose `event.origin` matches your configured `baseUrl`, so cross-origin iframes can't spoof events.\n\n## License\n\nMIT © [Alenta AI](https://alenta.ai)\n","readmeFilename":"README.md","_rev":"1-5fe2937d89c6233836130f797420aad0"}