talkgeniejs-staging
v1.0.8
Published
A JavaScript library for text-to-speech functionality
Downloads
233
Maintainers
Readme
TalkGenieJS
A lightweight, modern JavaScript library for embedding AI voice enabled widgets in any website.
Installation
NPM
npm install talkgeniejsCDN
<script src="https://unpkg.com/talkgeniejs@latest/dist/index.umd.js"></script>Browser (UMD)
<script type="text/javascript">
window.protoSettings = {
widgetUid:'<:agent-uuid>'
};
var prs = document.createElement('script');
prs.src = 'https://unpkg.com/talkgeniejs@latest/dist/index.umd.js';
prs.type = 'text/javascript';
prs.async = true;
document.head.appendChild(prs);
</script>Open / close from the host page
After the embed script loads, use window.Talkgenie or custom events:
<button type="button" onclick="window.Talkgenie.open()">Open chat</button>
<button type="button" onclick="window.Talkgenie.close()">Close chat</button>
<button type="button" onclick="window.Talkgenie.toggle()">Toggle chat</button>// Programmatic API
window.Talkgenie.open();
window.Talkgenie.close();
window.Talkgenie.toggle();
window.Talkgenie.isOpen(); // boolean
// Custom events (same behavior; useful for decoupled integrations)
window.dispatchEvent(new Event('talkgenie:open'));
window.dispatchEvent(new Event('talkgenie:close'));
window.dispatchEvent(new Event('talkgenie:toggle'));
// Listen when the user or host page changes open state
window.addEventListener('talkgenie:statechange', (e) => {
console.log('Widget open:', e.detail.open);
});Calls are queued until the widget host finishes initializing, so you can invoke them right after appending the script.
