Skip to Content
InsurgeDocumentation

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.

Developers
Markdown

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.

The SDK is distributed privately

Ask your Insurge contact for access. The packages install from a private registry once your team has been given read access.

What you get

PackageWhat it is
@insurge-ai/agent-clientThe meeting engine, with no UI: the connection, voice, mic and turns.
@insurge-ai/agent-reactReact bindings: a provider, hooks over the meeting's state, and <AgentStage>, the product the guide drives.
@insurge-ai/agent-uiReady-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:

Sign in to the registry
npm login --scope=@insurge-ai --auth-type=legacy --registry=https://npm.pkg.github.com

Start 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.

Create and run the starter
npx @insurge-ai/agent-ui create my-meeting --link YOUR_MEETING_LINK
cd my-meeting
npm run dev

Open 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 changeEdit
Colours, corners and shadowssrc/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 roomsrc/components/meeting/meeting-room.tsx
Which screen shows whensrc/components/meeting/meeting.tsx: loading, visitor form, join, room, end
How the meeting beginssrc/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 transcriptIts file in src/components/agent-ui/

The starter's README lists its optional settings.

Leave these as they are
  • src/lib/insurge.ts connects 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 any await. Browsers keep sound and the mic off until a click.
  • Keep exactly one spoken handler, or each spoken turn is sent twice.
  • public/voice is 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:

.npmrc
@insurge-ai:registry=https://npm.pkg.github.com
Install
npm install @insurge-ai/agent-client @insurge-ai/agent-react

Serve 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:

package.json scripts
{
  "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:

Vite
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

Copy components into your app
npx @insurge-ai/agent-ui list
npx @insurge-ai/agent-ui add call-bar transcript composer
npx @insurge-ai/agent-ui add --all

They 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
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:

meeting.tsx
"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:

room.tsx
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 />;
}
  • gate is loading until the workspace's settings arrive, then intake while the link's agent needs the visitor form, then ready.
  • The join button must call session.joinGesture() first thing in its click handler. The JoinScreen and IntakeForm components do this for you.
  • sessionOptions(link, { autoStart, intake }) takes the two starter choices. With autoStart: false, nothing starts until you call session.start({ topic }).

Session options

If you build the options yourself, these are the ones you'll set:

NameTypeDescription
apiUrl requiredstringWhere REST calls go: https://api.insurgeai.com, or your own origin when your dev server forwards.
wsUrl requiredstringThe meeting connection: wss://api.insurgeai.com/ws/stream
identity requiredobjectWho 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 requiredSpeechToTextThe visitor's speech-to-text, from createRelaySTT({ wsUrl, identity }). One per session.
deckstring | nullPresentation links: the presentation in the link. None opens the workspace's default.
autoStartbooleanStart 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:

A status line
const { phase, paused, speaking } = useSessionState((s) => ({
  phase: s.phase,
  paused: s.pause.paused,
  speaking: s.mic.speaking,
}));
FieldWhat it holds
connectionidle, connecting, open, reconnecting or failed
phaseidle, running, completed or ended
gateloading, intake or ready
messagesThe conversation, line by line
awaitingReplyThe visitor asked and the guide hasn't answered yet
interimThe visitor's words while they're still talking
captionThe line the guide is saying
promptA question the guide asked, with its quick replies
pausepaused, and when the pause ends
micThe mic's mode and whether it's live, muted, blocked or hearing speech
audio.blockedThe browser is still holding the sound back
languageThe meeting's language
stageWhat 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

ToCall
Send typed textsession.send(text)
Turn the mic on or offsession.mic.toggle()
Mute hands-free listeningsession.mic.setMuted(true)
Switch between push-to-talk and hands-freesession.mic.setMode("push_to_talk") or "hands_free". It takes effect only while mic.canSwitchMode is true.
Pause or resumesession.pause.set(true), session.pause.set(false) or session.pause.toggle()
Mute the guide's voicesession.conversation.setMuted(true)
Stop the guide mid-sentencesession.stopSpeaking()
Change the languagesession.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: falsesession.start({ topic }). The topic is used on /s/ links only, and the SDK cuts it at 500 characters.
Leavesession.end()
Try to reconnect nowsession.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.

EventWhen
leadThe visitor's details were saved: the form, or identify().
startedThe guide is running. Carries meetingId.
startFailedThe start was refused or failed for good.
firstAudioThe guide's voice started playing.
spokenThe visitor finished a spoken turn. Send it with session.send(text, "spoken").
unsentThe visitor's speech sent nothing, for example noise.
sendFailedA turn didn't reach Insurge.
agentActionThe guide acted on the page.
agentActivityThe guide said what it's doing, as a label.
agentDoneThe guide's run ended.
connectFailedThe connection has kept failing long enough to tell the visitor.
levelThe mic's level, from 0 to 1, on every audio frame.
pauseExpiredA 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.

PropWhat it does
camera"cinematic" (default), "subtle" or "off": how much the view follows the guide. Never on slides.
cameraMaxZoomHow far the camera may zoom, from 1 to 3.
placeholderWhat shows before there is anything to show.
onFirstFrameOn a streamed stage, called once when the first picture of the product paints.
className, styleYour styling.
childrenOverlays 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

ComponentWhat it does
TranscriptThe conversation, with quick replies and the visitor's words as they talk.
ComposerThe text box. Enter sends.
MicButtonThe mic, push-to-talk or hands-free, with a level ring.
CallBarMic, pause, speaker mute and leave. controls picks pause, speaker or both (default: your agent's setting); onLeave runs on leave.
AgentOrbAn orb that moves with the guide's voice.
StageThe stage in a frame, as above.
IntakeFormYour workspace's visitor form. mode is auto, proceed or finish.
JoinScreenThe 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.
AudioUnlockA prompt for a browser that still blocks the sound.
EndScreenThe 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. phase becomes ended: show your end screen.
  • When the guide's run finishes for good, phase becomes ended by itself. When it is completed, 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 connection reads reconnecting. If it keeps failing you get connectFailed; offer a button that calls session.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:

Run the starter's image
docker build --secret id=npmrc,src=$HOME/.npmrc -t meeting .
docker run -p 3000:3000 meeting

Tell 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.

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

Update
npm update @insurge-ai/agent-client @insurge-ai/agent-react @insurge-ai/agent-ui
npm run build

While 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:

Refresh one component
npx @insurge-ai/agent-ui add transcript --overwrite

Without --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 seeWhyWhat to do
npm install can't authenticate or can't find @insurge-ai packagesNo .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 localhostThe platform doesn't accept localhost pages.Forward /api, /storage and /static through your dev server.
Calls fail with a CORS error on your live hostInsurge hasn't added your host yet.Send your host to your Insurge contact.
The page stays on loadingThe workspace's settings never reached the session.Pass config to AgentSessionProvider, or call session.configure(config) yourself.
No sound until the visitor clicks againThe 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 twiceTwo spoken handlers.Keep one.
In development, spoken words go nowhereThe 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-freeThe 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 effectIt's fixed at build time.Build again.

On this page