Header Logo

How to Embed a Realtime Voice and Video Sales Avatar Widget with Node.js

How to Embed a Realtime Voice and Video Sales Avatar Widget with Node.js

Node.js guide to embed a realtime voice/video sales avatar, manage sessions via REST, and keep secrets server-side.

Introduction


If you are building a sales assistant, support agent, or product demo that speaks in realtime, the next obvious step is giving that agent a face. Not a cartoon overlay or a prerecorded clip, but a live avatar that tracks the conversation, lip-syncs accurately, and feels responsive enough to sit inside an actual customer flow.


Protoface is the layer that does that for developers: it turns a voice agent into a realtime video avatar you can embed in a web app or attach to an existing agent pipeline. In this post, I’ll focus on the Node.js path and the integration patterns that matter in production: how realtime voice/video avatars work, how to wire one into a Node backend, what to keep out of the browser, and where the trade-offs show up.


By the end, you should be able to:


  • reason about the architecture of a voice-and-video avatar without mixing up signaling, media, and app logic

  • create or manage avatar sessions from Node.js using the REST API

  • understand when to use a direct embed versus a backend-managed flow

  • avoid the common security and latency mistakes that make these systems brittle


How realtime voice avatars actually work


The implementation detail that matters most is that a “talking avatar” is not just video generation. It is a realtime media system with at least three moving parts:


  1. Text or audio input from the user.

  2. Speech and turn-taking logic from your agent stack.

  3. A synchronized video face that is updated continuously enough to look like it is speaking the emitted audio.


In practice, the agent pipeline usually produces audio in small chunks over a low-latency transport such as WebRTC. The avatar layer consumes that stream, aligns mouth motion and facial motion to the acoustic envelope, and returns a video track or rendered element that can be displayed alongside the conversation. If your turn-taking is sloppy, the avatar will look sloppy even if the video generation itself is good.


This is why integration quality is mostly about timing and session management:


  • Session identity keeps the avatar, voice agent, and browser client attached to the same conversation.

  • Transport choice affects latency and firewall compatibility.

  • Audio chunking affects how quickly the mouth begins moving after the agent starts speaking.

  • Client rendering affects whether the avatar feels embedded or just like a video widget pasted on top.


Node.js integration: use the backend for secrets and session orchestration


The clean Node.js pattern is simple: keep API keys on the server, create or manage avatar sessions there, and hand the browser only a short-lived session identifier or embed URL. Do not call an avatar management API directly from client-side JavaScript if it requires a long-lived key.


Protoface exposes a REST API at api.protoface.com for creating and managing avatars and realtime sessions. Exact request and response fields are in the docs, but the shape is standard: authenticate with a bearer API key, create a session, and pass the session reference to whatever runtime will stream media.


import express from "express";

app.listen(3000);
import express from "express";

app.listen(3000);
import express from "express";

app.listen(3000);


That pattern solves two problems at once. First, your API key never touches the browser. Second, you have one place to enforce app-specific policy: rate limits, custom instructions, user entitlements, and session expiration.


What to keep in the browser, and what not to


Browsers are fine for rendering and interaction, but they are the wrong place for privileged orchestration. For realtime avatars, the browser should generally do one of two things:


  • join an already authorized realtime session

  • render a customer-managed embed that handles the media plumbing for you


What should not happen is “open DevTools, copy the key, and now the client can create avatars forever.” That is a security bug, not a shortcut.


If you are building your own UI around the avatar, keep these rules in mind:


  • Use short-lived session tokens or signed URLs rather than static secrets.

  • Validate origin and user identity on the server before minting a session.

  • Treat avatar creation as a server-side policy decision, not a client-side convenience.

  • Measure end-to-end latency from user speech to avatar response, not just TTFB on your API.


Using the LiveKit agent path when the avatar is part of a voice agent


If your product already uses LiveKit for realtime voice, the lowest-friction route is to attach an avatar to the agent rather than inventing a separate media pipeline. Protoface provides a LiveKit Agents plugin, published as livekit-plugins-protoface on PyPI, which drops a synchronized talking video face into the agent flow.


The value here is architectural consistency. Your voice agent keeps handling speech recognition, response generation, interruption handling, and turn-taking, while the avatar plugin consumes the agent’s output and renders the visual layer. That keeps the avatar from becoming a second source of truth for conversation state.


A minimal agent setup looks like this conceptually:


from livekit.agents import WorkerOptions
from livekit.agents import WorkerOptions
from livekit.agents import WorkerOptions


The important constraint is that the plugin belongs on the server side of your agent process, not in the browser. If you are using LiveKit already, start from the plugin repo and examples in the GitHub organization, then map your existing agent events to the avatar lifecycle.


When an iframe embed is the right answer


Not every product needs a custom frontend integration. If the requirement is “put an interactive avatar on a site quickly, without exposing secrets,” the customer-managed iframe embed is the practical option.


The embed model is intentionally conservative: no backend to build, no API key in the browser, parent-origin allowlisting, per-embed voice and instructions, and rate limits at both the IP and duration level. For many sales or demo pages, that is exactly the right trade-off. You get a controlled surface that can be dropped into an existing website while keeping the operational and security boundary inside the embed.


That said, the iframe is not a substitute for a fully custom app when you need deep control over state, layout, or downstream events. Use it when the avatar is a bounded interaction surface. Use the API when the avatar is part of a larger product workflow.


Managing sessions from Node.js and checking the result


Once you have a session object, the operational work shifts to lifecycle management: create the session, surface it to the browser or agent, and clean it up when the conversation ends. The REST API is the right place to automate this.


curl -X POST https://api.protoface.com/v1/sessions \
}'
curl -X POST https://api.protoface.com/v1/sessions \
}'
curl -X POST https://api.protoface.com/v1/sessions \
}'


If you are using Node.js, a good operational pattern is to wrap session creation in a small service function that:


  1. validates the authenticated user in your app

  2. applies any plan-based limits or product rules

  3. creates the avatar session through the API

  4. stores the resulting session ID with your own conversation record


That makes it easy to answer questions later like “which user started this session,” “what instructions were active,” and “how many sessions did this customer run this month?” Those are the details that matter when you debug quality issues or usage bills.


Practical trade-offs: latency, quality tier, and UX


For realtime avatars, quality is not free. Higher fidelity generally means more compute, which affects cost and sometimes startup time. Protoface bills by quality tier, so you should choose the lowest tier that preserves the interaction you actually need. A sales avatar that lives in a sidebar does not usually need the same visual fidelity as a hero-unit demo.


Latency is the other constraint. A responsive system usually feels good when the assistant begins speaking quickly enough that the avatar’s mouth motion tracks the first word of the response. If your backend queues requests, your speech model is slow, or your media path does too much work on the client, the avatar becomes noticeably less convincing.


Two rules help here:


  • Keep the first response short and let the agent continue once the turn is established.

  • Avoid unnecessary hops between your backend, the agent runtime, and the avatar renderer.


In other words, the avatar should be attached to the conversation, not bolted on after the fact.


Conclusion


Embedding a realtime voice-and-video sales avatar is mostly a systems integration problem: keep secrets server-side, manage sessions centrally, and choose the right surface for the job. If you already run a voice agent, attach the avatar in the agent pipeline. If you need a controlled, fast web deployment, use the iframe embed. If you need custom orchestration, manage sessions from Node.js through the REST API.


For exact request shapes, supported fields, and current integration details, start with the docs. If you want a working starting point, the quickstarts linked from the repository README are the fastest way to get from “session created” to “avatar responding in a browser” without guessing at the plumbing.

Add a face to your AI.

No credit card needed.

Add a face to your AI.

No credit card needed.

Add a face to your AI.

No credit card needed.