JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 805
  • Score
    100M100P100Q85064F
  • License MIT

Capability-first voice AI SDK. Register your JS functions, and Gemini Live calls them when users speak or type.

Package Exports

  • @doweit/voice

Readme

@doweit/voice

Capability-first voice AI SDK for the web. Expose your JavaScript functions, and Gemini Live decides when and how to call them based on what your users say or type.

Install

npm install @doweit/voice

Quick start (React / Next.js)

import { DoweitClient, DoweitWidget } from "@doweit/voice";
import { useEffect, useState } from "react";

const client = new DoweitClient({
    publicKey: "dw_pub_...",   // grab from https://doweit.com dashboard
});

client.register({
    addToCart: {
        description: "Add an item to the shopping cart.",
        params: { itemId: { required: true }, qty: { required: true } },
        handler: async ({ itemId, qty }) => {
            await fetch(`/api/cart`, { method: "POST", body: JSON.stringify({ itemId, qty }) });
            return { status: "ok" };
        },
    },
});

export default function App() {
    const [ready, setReady] = useState(false);
    useEffect(() => { client.init().then(() => setReady(true)); }, []);
    return ready ? <DoweitWidget client={client} /> : null;
}

Quick start (plain HTML / CDN)

<script src="https://cdn.jsdelivr.net/npm/@doweit/voice/dist/index.global.js"></script>
<script>
    const client = new Doweit.DoweitClient({ publicKey: "dw_pub_..." });

    client.register({
        scrollToSection: {
            description: "Scroll the page to a named section.",
            params: { sectionId: { required: true } },
            handler: ({ sectionId }) => {
                document.getElementById(sectionId)?.scrollIntoView({ behavior: "smooth" });
                return { status: "ok" };
            },
        },
    });

    client.init();
</script>

Core concepts

  • Capability-first: you describe what your app can do (register), and the AI decides which capability matches the user's intent. No predefined intents, no string matching.
  • Manifest sync: client.init() ships a snapshot of your registered actions to the Doweit dashboard so you can inspect, version and gate them.
  • Live state: use client.bindState(() => ({ cart, page })) so the AI always sees the current UI without you injecting prompts.
  • Server-proxied: the SDK never talks to Google directly — your publishable key is safe to ship in the browser.

API

new DoweitClient(config)

  • publicKey (required): your project's publishable key.
  • baseUrl (optional): override the Doweit backend URL. Defaults to same-origin.
  • language (optional): ISO code, e.g. "en".

client.register(actions)

Register one or more capabilities:

client.register({
    bookTable: {
        description: "Reserve a table.",
        params: { guests: { type: "number", required: true }, time: { required: true } },
        scope: "global",          // or a route prefix like "/restaurant"
        dangerous: false,         // if true, prompts for confirmation
        handler: async (args) => { /* ... */ },
    },
});

client.bindState(getter)

Reactively expose current UI state to the AI:

client.bindState(() => ({ cart: getCart(), currentPage: location.pathname }));

client.setUser({ userId, email })

Identify the end-user so memory persists across sessions.

client.use((action, next) => ...)

Middleware for validation, logging, or blocking dangerous calls.

client.enableNavigation(router)

Auto-registers a navigate action wired to your router (Next.js, React Router, etc.).

<DoweitWidget client={client} />

Drop-in chat bubble UI with voice + text. Or use the useDoweitVoice(client) hook to build your own.

Documentation

Full docs and interactive examples: https://doweit.com/docs/voice-sdk

License

MIT © Doweit