ai-voice-bot-widget
v0.1.0
Published
Embeddable, Shadow-DOM-isolated chat + voice widget (tap-to-talk, neural TTS) for the AI Voice Bot agent. Zero runtime deps, ~5.5 KB gzipped.
Maintainers
Readme
ai-voice-bot-widget
Embeddable chat widget (text-first) for the AI Voice Bot. Self-mounting, zero-dep, Shadow-DOM isolated.
Build & test
cd widget
npm install
npm test # unit tests (config, SSE client, session, DOM via happy-dom)
npm run build # -> dist/ai-voice-bot.min.jsLocal smoke
- In another terminal, run the Worker:
cd ../worker && npm run dev(http://localhost:8787). AddMODE=devtoworker/.dev.varsto bypass guards while testing. cd widget && npm run build- Open
widget/demo-embed.htmlin a browser.
Voice (v0.2c)
- Tap-to-talk mic: appears next to Send; disabled with a hint in browsers without
SpeechRecognition(Safari/Firefox) — text still works. - Leo speaks back: neural voice via the Worker's
/tts(Groqplayai-tts), falling back to the browser'sspeechSynthesis, falling back to silent (the transcript is always there). - Leo speaks automatically when you used the mic; the 🔊/🔇 toggle in the header forces sound on/off for typed messages too.
- One-time setup: the Groq
playai-ttsmodel requires accepting its terms once in the Groq console under that model. Until accepted (or without aGROQ_API_KEY),/ttsreturns an error and the widget automatically falls back to browser TTS — voice still works. - Set
MAX_TTS_CHARS/TTS_VOICEinworker/wrangler.toml[vars]to tune the text cap / default voice.
Embed on a site
<script>window.AiVoiceBotConfig = { workerUrl: "https://voicebot.devmohan.in", /* branding, privacy, ... */ };</script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/ai-voice-bot.min.js" defer></script>Pin a version (@0.1.0) for reproducible embeds, or drop the version for jsDelivr's latest. The
package isn't published to npm yet — until then, use the locally-built dist/ai-voice-bot.min.js.
Publishing (maintainer notes)
cd widget
npm login # once, if not already
npm publish # runs typecheck + test + build via prepublishOnly, then publishesjsDelivr and unpkg mirror npm automatically — no separate CDN step needed. Bump version in
package.json (and the CDN URL above) before each publish.
