Skip to content

React: hooks and components

@morevoice/react wraps the browser call client of @morevoice/web for React: hooks that hold a call’s state and its live transcript, and ready-made components for a talk button and an agent’s softphone.

The package exports:

Export Kind What it does
MoreVoiceProvider component Shares one call configuration and one call with every MoreVoice hook and component inside it.
MoreVoiceContext component The React context that MoreVoiceProvider fills (read it with useMoreVoiceContext).
useMoreVoiceContext hook The nearest provider’s value, or null outside one.
CallController class The call store.
INITIAL_SNAPSHOT const The snapshot before any call (and on the server).
isActivePhase const Is a call being set up or in progress?
MAX_TRANSCRIPT_LINES const The most transcript lines kept (a long call stays cheap to render).
toCallError function Any thrown value → CallError.
tokenFromBody function { token } / { client_token } (+ ws_url) from a token endpoint, as the talk button reads it.
CALL_EVENT_TYPES const The call events GET /v1/calls/{id}/events streams (and webhooks carry).
useCall hook The spec’s name for useMoreVoiceCall: useCall() → { start, hangup, mute, sendDtmf, phase, callId, error, … }.
useCallEvents hook A call’s live events, from your own server (server-side proxy only: the API needs a secret key).
useCallState hook The call’s snapshot: phase, AI state, call id, mute, error, transcript, timings.
useMoreVoiceCall hook A browser call with a MoreVoice assistant.
useNow hook The current time, ticking once a second while active (for call timers).
useTalkButton hook A headless talk button: the call plus everything a button of your own design needs (label, status line, timer, error text and accessible props), in Hebrew or English.
useTranscript hook The live transcript, oldest first: a partial line is replaced by its final text in place.
TalkButton component The talk button.
CallStatus component The call’s state, its timer and its error, in one accessible status line.
LiveTranscript component The live transcript of the call.
dirOf const The text direction of a language: “rtl” for Hebrew.
formatDuration function 65 000 ms → “01:05”; an hour or more → “1:01:05”.
pickLang function “he”, “he-IL” and the legacy “iw” are Hebrew; everything else is English.
STRINGS const The components’ built-in strings, in English and Hebrew (override any of them with labels).

@morevoice/web works in any React app as it is:

  • The talk button is a standard custom element: render <morevoice-talk-button> with its attributes after loading the script or importing @morevoice/web/define once, set metadata or auth on it through a ref, and listen to its morevoice-… events with addEventListener in an effect.
  • Your own UI creates a MoreVoiceCall in an effect, subscribes to its events into state, and calls destroy() in the effect’s cleanup, so leaving the page never leaves a microphone open.

Calls placed from the browser are authorised as described in who may call.