Build your own meeting page
Use the Meeting SDK to run Insurge meetings on a page you design and host, with the guide's voice, the visitor's mic and the live product stage handled for you.
The Meeting SDK is for teams who want the meeting page a visitor sees to be their own: their layout, their brand, their domain. The meeting itself comes from the SDK: the connection, the guide's voice, the visitor's mic, turn-taking, pause, reconnects and the stage where the guide shows your product. Everything on screen is React that you own and can change.
Ask your Insurge contact for access. The packages install from a private registry once your team has been given read access.
What you get
| Package | What it is |
|---|---|
@insurge-ai/agent-client | The meeting engine, with no UI: the connection, voice, mic and turns. |
@insurge-ai/agent-react | React bindings: a provider, hooks over the meeting's state, and <AgentStage>, the product the guide drives. |
@insurge-ai/agent-ui | Ready-made meeting components, copied into your app as source so you own them. It also creates a complete starter app. |
The three packages are released together, always on the same version. This page describes version 0.2.
Before you start
- Node 20 or newer.
- React 19, for
@insurge-ai/agent-react. - Tailwind 3.4 and
lucide-react, if you use the ready-made components. - A GitHub account for each person, or build account, that installs the packages.
- A host for your meeting page, served over HTTPS so visitors can talk.
- A meeting link to test with: on the agent's Sharing tab in the dashboard, select Create link.
Browsers. Hands-free listening needs AudioWorklet, Web Workers, WebAssembly with SIMD and microphone access. Where any of those is missing, the mic falls back to push-to-talk by itself. handsFreeSupported() from @insurge-ai/agent-client tells you whether the browser can run hands-free.
Get access
Ask for read access
Send your Insurge contact the GitHub usernames of the people, or the build account, who will install the SDK. Insurge grants them read access to the packages.
Create a token
In GitHub, go to Settings, Developer settings, Personal access tokens, Tokens (classic). Create a token with the read:packages scope only. The registry accepts classic tokens only.
Sign in once per computer
Your GitHub username is the user name, and the token is the password:
npm login --scope=@insurge-ai --auth-type=legacy --registry=https://npm.pkg.github.comStart from the starter app
The quickest way in is a complete meeting page, as a Next.js app you own, with every component in place. Most teams start here and change the look.
npx @insurge-ai/agent-ui create my-meeting --link YOUR_MEETING_LINK
cd my-meeting
npm run devOpen http://localhost:3000 and your guide joins. Without --link, it opens an Insurge sample meeting. Any link from your dashboard also opens locally: replace its host with http://localhost:3000. Add --no-install to skip npm install.
| To change | Edit |
|---|---|
| Colours, corners and shadows | src/components/agent-ui/agent-ui.css. The accent is one variable, --accent-rgb; your workspace's brand colour replaces it when the page loads. |
| What sits where in the room | src/components/meeting/meeting-room.tsx |
| Which screen shows when | src/components/meeting/meeting.tsx: loading, visitor form, join, room, end |
| How the meeting begins | src/meeting.config.ts: start at once, or ask the visitor what they came for (topic); ask for their details before the meeting or at the end (intake). In npm run dev, try the other choice with ?topic=ask or ?intake=after on the link. |
| One piece, such as the mic or the transcript | Its file in src/components/agent-ui/ |
The starter's README lists its optional settings.
src/lib/insurge.tsconnects the page to Insurge: who the browser tab is, the mic's connection and the config fetch.- The session is created once per page, inside
useState. Don't move it to a module variable or share one speech-to-text between two sessions: React's StrictMode builds the session twice in development, and a shared one sends the visitor's words to the copy React threw away. session.joinGesture()runs inside the visitor's click, before anyawait. Browsers keep sound and the mic off until a click.- Keep exactly one
spokenhandler, or each spoken turn is sent twice. public/voiceis generated. Don't commit or edit it.
Add it to an app you already have
Install the packages
Commit an .npmrc that names the registry, with no token in it:
@insurge-ai:registry=https://npm.pkg.github.comnpm install @insurge-ai/agent-client @insurge-ai/agent-reactServe the voice files
Hands-free listening needs files your app serves. Copy them before each dev run and build, and add public/voice to .gitignore:
{
"predev": "insurge-voice-assets public/voice",
"prebuild": "insurge-voice-assets public/voice"
}They are served from /voice by default; voice.assetBaseUrl moves them. The model files' names carry their version, so /voice/models/ can be cached for good.
Check the voice worker
Next.js and Vite's production build find the worker with no help. Vite's dev server doesn't, so with Vite pass it in:
import workerUrl from "@insurge-ai/agent-client/voice.worker.js?url";
createAgentSession({ /* your options */ voice: { workerUrl } });With no bundler, use the copy in the voice folder: voice: { workerUrl: "/voice/voice.worker.js" }. The worker must come from your page's own origin.
Add the components you want
npx @insurge-ai/agent-ui list
npx @insurge-ai/agent-ui add call-bar transcript composer
npx @insurge-ai/agent-ui add --allThey go to src/components/agent-ui (or components/agent-ui without src); --dir picks another folder. Then install lucide-react and Tailwind 3.4, import agent-ui.css at the top of your global stylesheet, and add the folder to Tailwind's content.
Copy the connection file
Copy src/lib/insurge.ts from a starter app into yours. It builds the session's options for a link and fetches the workspace's public settings. The examples below use it. It is written for Next.js and reads its settings from process.env; in another framework, such as Vite, change those reads to your framework's.
Forward requests while you develop
The platform doesn't accept calls from a localhost page. In development, have your dev server forward /api, /storage and /static to https://api.insurgeai.com, and call it through your own origin. The starter's dev server does this; copy its next.config.mjs if you use Next.js.
In a Docker build, pass your .npmrc as a build secret, never as a build argument, so the token never lands in an image:
docker build --secret id=npmrc,src=$HOME/.npmrc -t meeting .Inside the Dockerfile, install with RUN --mount=type=secret,id=npmrc,target=/root/.npmrc npm ci.
How a meeting page signs in
There is no API key in a meeting page. Each meeting is opened by the code in its link, which the SDK sends with every call, together with an id your page makes for each browser tab. A second tab is a second meeting.
- The platform accepts calls only from hosts Insurge has allowed. Tell your Insurge contact your meeting host before you go live.
- Never put a workspace API key in a meeting page. Keys are for your servers: see API keys.
Start a session
Create the session once, in useState, and wrap your meeting in AgentSessionProvider:
"use client";
import { useEffect, useState } from "react";
import { createAgentSession } from "@insurge-ai/agent-client";
import { AgentSessionProvider } from "@insurge-ai/agent-react";
import {
WS_URL,
fetchWorkspaceConfig,
sessionOptions,
type LinkInfo,
type WorkspaceConfig,
} from "@/lib/insurge";
export function Meeting(link: LinkInfo) {
const [config, setConfig] = useState<WorkspaceConfig | null>(null);
const [session] = useState(() => createAgentSession(sessionOptions(link)));
useEffect(() => {
void fetchWorkspaceConfig(link).then(setConfig);
}, []);
return (
<AgentSessionProvider session={session} wsUrl={WS_URL} attach config={config}>
<Room />
</AgentSessionProvider>
);
}link is { surface: "support", token } for a /s/ link, or { surface: "presentation", token, deck } for a /p/ link, with the code from the address as token. deck is the part after the code; leave it out for a /p/CODE link, which opens the workspace's default presentation.
Inside the provider, read the session and send what the visitor says:
import { useAgentSession, useSessionEvent, useSessionState } from "@insurge-ai/agent-react";
function Room() {
const session = useAgentSession();
const gate = useSessionState((s) => s.gate);
// Exactly one of these in the app.
useSessionEvent("spoken", ({ text }) => {
void session.send(text, "spoken");
});
if (gate === "loading") return null;
if (gate === "intake") return <IntakeForm />;
return <MeetingRoom />;
}gateisloadinguntil the workspace's settings arrive, thenintakewhile the link's agent needs the visitor form, thenready.- The join button must call
session.joinGesture()first thing in its click handler. TheJoinScreenandIntakeFormcomponents do this for you. sessionOptions(link, { autoStart, intake })takes the two starter choices. WithautoStart: false, nothing starts until you callsession.start({ topic }).
Session options
If you build the options yourself, these are the ones you'll set:
| Name | Type | Description |
|---|---|---|
apiUrl required | string | Where REST calls go: https://api.insurgeai.com, or your own origin when your dev server forwards. |
wsUrl required | string | The meeting connection: wss://api.insurgeai.com/ws/stream |
identity required | object | Who this tab is: the link's code and the tab's id. Build it as the connection file does. |
surface required | "support" | "presentation" | Which kind of link this is. |
stt required | SpeechToText | The visitor's speech-to-text, from createRelaySTT({ wsUrl, identity }). One per session. |
deck | string | null | Presentation links: the presentation in the link. None opens the workspace's default. |
autoStart | boolean | Start the guide as soon as it can. false waits for session.start().Default: true |
intake | "before" | "after" | When a link that asks for details asks: before the meeting, or at the end.Default: "before" |
voice | { workerUrl?, assetBaseUrl? } | Where the voice worker and files are, when not the defaults. |
Read the meeting's state
useSessionState(select) returns the part of the state you pick, and re-renders only when it changes:
const { phase, paused, speaking } = useSessionState((s) => ({
phase: s.phase,
paused: s.pause.paused,
speaking: s.mic.speaking,
}));| Field | What it holds |
|---|---|
connection | idle, connecting, open, reconnecting or failed |
phase | idle, running, completed or ended |
gate | loading, intake or ready |
messages | The conversation, line by line |
awaitingReply | The visitor asked and the guide hasn't answered yet |
interim | The visitor's words while they're still talking |
caption | The line the guide is saying |
prompt | A question the guide asked, with its quick replies |
pause | paused, and when the pause ends |
mic | The mic's mode and whether it's live, muted, blocked or hearing speech |
audio.blocked | The browser is still holding the sound back |
language | The meeting's language |
stage | What the stage shows: the page or the slide |
Other hooks: useConnection(), useTurnStatus(inputs) (a turn status worked out from signals your page passes in), useLevel("mic") and useLevel("agent") for voice levels, and useAgentAudio().
Controls
| To | Call |
|---|---|
| Send typed text | session.send(text) |
| Turn the mic on or off | session.mic.toggle() |
| Mute hands-free listening | session.mic.setMuted(true) |
| Switch between push-to-talk and hands-free | session.mic.setMode("push_to_talk") or "hands_free". It takes effect only while mic.canSwitchMode is true. |
| Pause or resume | session.pause.set(true), session.pause.set(false) or session.pause.toggle() |
| Mute the guide's voice | session.conversation.setMuted(true) |
| Stop the guide mid-sentence | session.stopSpeaking() |
| Change the language | session.language.set(code). A language your workspace's voice can't speak is refused: the choice goes back, and a note in the conversation says why. |
Start, with autoStart: false | session.start({ topic }). The topic is used on /s/ links only, and the SDK cuts it at 500 characters. |
| Leave | session.end() |
| Try to reconnect now | session.retryConnect() |
A pause left longer than 15 minutes ends the meeting, and the session fires pauseExpired. phase doesn't change by itself then: call session.end() when it fires, as the starter does, so your end screen shows.
Events
Listen with useSessionEvent(name, handler) in a component, or session.on(name, handler), which returns a function that stops listening.
| Event | When |
|---|---|
lead | The visitor's details were saved: the form, or identify(). |
started | The guide is running. Carries meetingId. |
startFailed | The start was refused or failed for good. |
firstAudio | The guide's voice started playing. |
spoken | The visitor finished a spoken turn. Send it with session.send(text, "spoken"). |
unsent | The visitor's speech sent nothing, for example noise. |
sendFailed | A turn didn't reach Insurge. |
agentAction | The guide acted on the page. |
agentActivity | The guide said what it's doing, as a label. |
agentDone | The guide's run ended. |
connectFailed | The connection has kept failing long enough to tell the visitor. |
level | The mic's level, from 0 to 1, on every audio frame. |
pauseExpired | A pause ran past its limit and ended the meeting. |
Show the guide's screen
<AgentStage> shows what the guide is doing: your product, or the slides. It fills its parent, so give the parent a size, and it is positioned so you can lay your own overlays over it as children.
| Prop | What it does |
|---|---|
camera | "cinematic" (default), "subtle" or "off": how much the view follows the guide. Never on slides. |
cameraMaxZoom | How far the camera may zoom, from 1 to 3. |
placeholder | What shows before there is anything to show. |
onFirstFrame | On a streamed stage, called once when the first picture of the product paints. |
className, style | Your styling. |
children | Overlays drawn on top. |
How the product reaches the stage follows your workspace's settings by default; leave it to them. The ready-made Stage component wraps <AgentStage> with the page title, a paused banner with Resume, and a reconnecting notice.
Ready-made components
| Component | What it does |
|---|---|
Transcript | The conversation, with quick replies and the visitor's words as they talk. |
Composer | The text box. Enter sends. |
MicButton | The mic, push-to-talk or hands-free, with a level ring. |
CallBar | Mic, pause, speaker mute and leave. controls picks pause, speaker or both (default: your agent's setting); onLeave runs on leave. |
AgentOrb | An orb that moves with the guide's voice. |
Stage | The stage in a frame, as above. |
IntakeForm | Your workspace's visitor form. mode is auto, proceed or finish. |
JoinScreen | The one click that turns on sound and asks for the mic. With topic, it asks what the visitor came for and starts the guide on it; pair it with autoStart: false, or the guide starts twice. |
AudioUnlock | A prompt for a browser that still blocks the sound. |
EndScreen | The screen after the meeting. |
They are accessible as shipped: labelled controls, a polite live region for the conversation, visible focus and reduced motion when the visitor asks for it. Keyboard, with CallBar: Space to talk, K to pause or resume, Escape to cancel leaving. Keep these when you restyle.
Ending and reconnecting
session.end()closes the mic, stops the guide and ends the meeting.phasebecomesended: show your end screen.- When the guide's run finishes for good,
phasebecomesendedby itself. When it iscompleted, the guide has stopped but the visitor can still ask, and a question brings it back. - If the connection drops, the session reconnects by itself and
connectionreadsreconnecting. If it keeps failing you getconnectFailed; offer a button that callssession.retryConnect(). - Reloading the page, or opening the link in a new tab, starts a new meeting.
- Version 0.2 doesn't open continue links on its own. Ask your Insurge contact before you build on them.
Go live
Build and serve it
Build your app and serve it on your meeting host over HTTPS. The starter builds as a Docker image:
docker build --secret id=npmrc,src=$HOME/.npmrc -t meeting .
docker run -p 3000:3000 meetingTell Insurge your host
Send your Insurge contact the address your page is served from, such as https://meet.example.com. The platform accepts calls from it once Insurge has added it. This is the one step that needs Insurge.
Share links on your host
The starter answers the same paths as Insurge's: /s/CODE for a guide, /p/CODE/PRESENTATION for a presentation. If you built your own app, give it the same routes. Take a link from the dashboard and replace its host with yours.
Settings that start with NEXT_PUBLIC_ are built into the page. Changing one needs a new build; restarting a container keeps the old value.
If your meeting page sends a Content-Security-Policy, it must allow connections to https://api.insurgeai.com and wss://api.insurgeai.com. The stage also shows your product, and on presentation links Insurge's slides, in a frame: allow those in frame-src too, and ask your Insurge contact which host the slides come from.
Update the SDK
npm update @insurge-ai/agent-client @insurge-ai/agent-react @insurge-ai/agent-ui
npm run buildWhile the SDK is on 0.x, npm update stays within the minor version you have (0.2.x). To move to a new minor version, install the packages by version, for example npm install @insurge-ai/agent-client@latest @insurge-ai/agent-react@latest, and keep the three on the same version.
The next dev run or build refreshes the voice files for the new version. Components you copied never change by themselves; to take a newer one, copy it again and redo your changes on top:
npx @insurge-ai/agent-ui add transcript --overwriteWithout --overwrite, files you already have are kept. Each page reports its SDK version when it connects, and newer features are sent only to pages that understand them, so an older version keeps working. Versions follow semver, but while the SDK is on 0.x a minor release may need a change in your code: read its release notes.
Troubleshooting
| What you see | Why | What to do |
|---|---|---|
npm install can't authenticate or can't find @insurge-ai packages | No .npmrc scope line, you aren't signed in, the token isn't classic or lacks read:packages, or your account hasn't been given access. | Check each, then sign in again with npm login. |
Calls fail with a CORS error on localhost | The platform doesn't accept localhost pages. | Forward /api, /storage and /static through your dev server. |
| Calls fail with a CORS error on your live host | Insurge hasn't added your host yet. | Send your host to your Insurge contact. |
| The page stays on loading | The workspace's settings never reached the session. | Pass config to AgentSessionProvider, or call session.configure(config) yourself. |
| No sound until the visitor clicks again | The join click didn't call session.joinGesture() before an await. | Call it first in the click handler, and show AudioUnlock while audio.blocked is true. |
| Each spoken turn is sent twice | Two spoken handlers. | Keep one. |
| In development, spoken words go nowhere | The session is created outside useState, or two sessions share one speech-to-text. | Create it in useState(() => createAgentSession(...)) with fresh options each time. |
| Only push-to-talk, never hands-free | The agent's Microphone setting is Push to talk, the browser lacks a feature hands-free needs, the voice files aren't served at /voice, or Vite's dev server broke the worker address. | Check the agent's Listening settings and handsFreeSupported(), run the voice-file script, and pass workerUrl with Vite. |
A changed NEXT_PUBLIC_ setting has no effect | It's fixed at build time. | Build again. |
In-app install reference
Put a copilot, onboarding or training agent inside your signed-in product with one tag, tell it who the user is, and decide what it may do on the page.
Continue links
Let a visitor who left a session part way carry on where they stopped, with a private link your server makes through the API.