Browser SDK (@rydhm/web)
@rydhm/web puts a Rydhm voice expert inside your web app (Onboarding coach) and gives your reps a browser phone (Softphone). It uses a publishable key or a softphone token, never your secret key. Typed, safe by default, and loadable with one script tag.
The script follows the Rydhm app: https://staging.rydhm.ai/engine.js in early access, https://app.rydhm.ai/engine.js at launch (the coach’s Setup tab shows the right one). It is always the current release. A CDN copy of a version published to npm works too, such as https://cdn.jsdelivr.net/npm/@rydhm/web@0.3.0/dist/engine.js; pin a version in production.
npm and the script tag match. npm install @rydhm/web installs 0.3.0, the release this page describes, the same as the script tag serves today. The script tag always follows the current release; pin a version from npm or the CDN for production.
Rydhm.init options
With the script tag, these options have a data-* form: data-api-url, data-ui="none", data-position, data-theme, data-accent, data-language, data-navigate="reload", data-debug, data-resume="false", data-learn-pages="false", data-user-id, data-user-hash, data-user-name, and data-auto-init="false" to wait for your own Rydhm('init', …).
The queue stub
Add the stub before the script, and every call made before engine.js has loaded is replayed when it does:
After load both styles work: Rydhm('start') and Rydhm.start(). Rydhm.instance is the instance and Rydhm.Softphone the softphone class. A queued Rydhm('init', { … }) is merged over the data-* options: the way to pass a function such as your router.
Methods
A typed conversation (mode: 'text') is the same conversation with audio off: the coach answers from its knowledge and uses every page tool and guide, and it is billed like chat, per token. Which modes an expert offers comes from its widget setting Visitors can; a mode it does not offer is refused with mode_not_available.
Events
Error codes
Softphone
See Browser softphone for the walkthrough.
A REC badge
When a call is recorded, the softphone gets a call.recording event the moment the recording starts, at the answer. It comes through the event listener, with CallRecordingData as its data:
The event reaches 0.3.0 too; the CallRecordingData type comes in the next release.
Exports
Rydhm, Softphone, VERSION, RISKY_PHRASES (the words that make a click ask first), the protocol constants (ROUTES, RPC_TOOL_METHOD, TOPIC_EVENTS, TOPIC_COMMAND, ATTR, LK, BUILTIN_TOOLS, DEFAULT_API_URL), and the types of every option, event and wire message (RydhmOptions, RydhmEvents, ToolDefinition, EngineEvent, SoftphoneEvents, IncomingCall, CallRecordingData…).
Browser support, size and CSP
- Current Chrome, Edge, Firefox and Safari, desktop and mobile (iOS Safari 15+). Needs WebRTC, Shadow DOM and Custom Elements. The script bundle targets ES2019.
- Two files for the script tag.
engine.jsis the loader (0.3.0: 184 KB raw, about 60 KB gzipped): the bubble, guides, announcements and page tools. The first time a conversation starts (a coach session, or a softphone going online), it addsengine-livekit.js(the voice connection, 739 KB raw, about 200 KB gzipped) from the same directory asengine.js. Visitors who never talk never download it. To host the files yourself, keep them side by side, or setdata-livekit-srcon the tag to whereengine-livekit.jsis. Both files must come from the same release. - With npm, there is no second file:
livekit-clientis a dependency your bundler splits into its own chunk, loaded on the first conversation. - Content Security Policy: allow both script files in
script-src(the origin they come from, such ashttps://staging.rydhm.ai, laterhttps://app.rydhm.ai). If your policy uses a nonce, put it on theengine.jstag: the loader copies it to theengine-livekit.jstag it adds. Allow the API address and your LiveKit host (wss:andhttps:) inconnect-src, and the expert’s photo host inimg-src. Styles use constructable stylesheets, so'unsafe-inline'isn’t needed. Sites that enforce Trusted Types addrydhmto theirtrusted-typeslist. - No cookies, no external fonts, no third-party requests.