What is the Web SDK?
The Web SDK is a small piece of code you drop into your website. When a visitor clicks a “Talk to us” button, it opens a live voice conversation with your OneInbox agent — right in the browser, using their microphone. Think of it like a live chat widget, but for voice. What it handles for you:- Asking the browser for microphone permission
- Streaming audio in real time (both directions)
- Showing live transcripts as the conversation happens
- Mute, unmute, and hang up
- An agent on OneInbox (the AI that answers)
- A button or widget on your site that starts the call
Quick steps — the simplest way to add it to your site
This is the fastest path: a publishable key + the Web SDK, no backend required.Create your agent
Build the agent that will answer calls — see Quickstart if you haven’t made one yet. Save its
id (agt_…).Create a publishable key
In the OneInbox dashboard, go to Settings → Publishable Keys → Create key. Enter the allowed origins for this key — one per line:
Copy the key — it starts with
| What to enter | When to use |
|---|---|
https://yoursite.com | Restrict the key to a specific domain — requests from any other origin are rejected with 403 ORIGIN_NOT_ALLOWED |
https://yoursite.com + https://staging.yoursite.com | Multiple specific domains (e.g. production + staging) |
* or leave blank | Allow all origins — useful during development or for internal tools where locking to a domain isn’t needed |
oi_pk_live_….Wire it to your agent
Initialize the SDK with your publishable key, then point
start() at your agent’s id:How it fits into your product
When a visitor clicks “Call”:- Your website asks your server: “start a call for this visitor”
- Your server creates the call via the OneInbox API and gets back a short-lived access token
- The Web SDK uses that token to connect the visitor’s browser to the agent
- The conversation starts — live, two-way voice
Two packages
| Package | Use it when |
|---|---|
@oneinbox/web-sdk | Plain JavaScript or any framework |
@oneinbox/web-sdk-react | React apps — gives you a ready-made hook |
Install
Vanilla example
What you can listen to
| Event | What it means |
|---|---|
call-start | The call connected — show your active call UI |
call-end | The call ended — return to idle state |
transcript | A new line of speech was heard — update captions or a chat log |
speech-start / speech-end | Someone started or stopped speaking — animate a speaking indicator |
volume-level | How loud the visitor’s mic is right now (0–1) — drive a mic level bar |
error | Something went wrong — show an error message |
Controls
| Method | What it does |
|---|---|
oi.start(agentId, { variables }) | Start the call |
oi.stop() | End the call |
oi.setMuted(true / false) | Mute or unmute the visitor’s mic |
oi.isMuted() | Returns true if the mic is currently muted |
oi.status | Current state: idle, connecting, active, or ending |
React example
useOneInbox() gives you everything you need to build a call UI:
| Value | What it is |
|---|---|
status | Current call state (idle, connecting, active, ending) |
transcripts | Every line of the conversation so far |
isAgentSpeaking | true while the agent is talking |
isMuted | true if the visitor’s mic is muted |
volume | Mic level in real time (0–1) |
error | The last error, if any |
start / stop / setMuted | Controls |