Skip to main content

react

Interfaces

DelphiClientProviderProps

Defined in: react/context.tsx:19

Properties

children
children: ReactNode;

Defined in: react/context.tsx:22

config?
optional config?: DelphiConfig;

Defined in: react/context.tsx:21

Initial configuration. Can be omitted when using DelphiConfigInit to push config later.


UseDelphiSessionOptions

Defined in: react/useDelphiSession.ts:45

Properties

appName?
optional appName?: string;

Defined in: react/useDelphiSession.ts:53

Optional human-readable app label

autoPlayAudio?
optional autoPlayAudio?: boolean;

Defined in: react/useDelphiSession.ts:64

Whether to auto-play assembled audio responses (default true).

endpointId
endpointId: string | null;

Defined in: react/useDelphiSession.ts:47

Endpoint to open (or reuse) a session against. null keeps the hook idle.

endpointName?
optional endpointName?: string;

Defined in: react/useDelphiSession.ts:51

Optional human-readable endpoint label

mode
mode: SessionMode;

Defined in: react/useDelphiSession.ts:49

Session mode used when opening for the first time. Ignored on reuse.

onAction?
optional onAction?: ActionHandler;

Defined in: react/useDelphiSession.ts:55

onAudio?
optional onAudio?: (audio: BrowserAudioEvent, message: ChannelMessage) => void;

Defined in: react/useDelphiSession.ts:60

Parameters
ParameterType
audioBrowserAudioEvent
messageChannelMessage
Returns

void

onChat?
optional onChat?: (chat: ChatPayload, message: ChannelMessage) => void;

Defined in: react/useDelphiSession.ts:57

Parameters
ParameterType
chatChatPayload
messageChannelMessage
Returns

void

onConnectionChange?
optional onConnectionChange?: (state: SessionConnectionState) => void;

Defined in: react/useDelphiSession.ts:61

Parameters
ParameterType
stateSessionConnectionState
Returns

void

onControl?
optional onControl?: (control: ControlPayload, message: ChannelMessage) => void;

Defined in: react/useDelphiSession.ts:59

Parameters
ParameterType
controlControlPayload
messageChannelMessage
Returns

void

onError?
optional onError?: (error: Error) => void;

Defined in: react/useDelphiSession.ts:62

Parameters
ParameterType
errorError
Returns

void

onMessage?
optional onMessage?: MessageHandler;

Defined in: react/useDelphiSession.ts:56

onStatus?
optional onStatus?: (status: StatusPayload, message: ChannelMessage) => void;

Defined in: react/useDelphiSession.ts:58

Parameters
ParameterType
statusStatusPayload
messageChannelMessage
Returns

void


UseDelphiSessionReturn

Defined in: react/useDelphiSession.ts:67

Properties

audioDone
audioDone: (responseId?: string) => Promise<BrowserAudioEvent>;

Defined in: react/useDelphiSession.ts:110

Parameters
ParameterType
responseId?string
Returns

Promise<BrowserAudioEvent>

clearMessages
clearMessages: () => void;

Defined in: react/useDelphiSession.ts:114

Clear the visible message history

Returns

void

close
close: () => Promise<void>;

Defined in: react/useDelphiSession.ts:112

Close the session immediately. Otherwise it stays open until idle timeout or unmount-with-zero-refcount.

Returns

Promise<void>

connected
connected: boolean;

Defined in: react/useDelphiSession.ts:71

connectionState
connectionState: SessionConnectionState;

Defined in: react/useDelphiSession.ts:70

disableTextChat
disableTextChat: () => boolean;

Defined in: react/useDelphiSession.ts:96

Returns

boolean

enableTextChat
enableTextChat: (responseMode?: ResponseMode) => boolean;

Defined in: react/useDelphiSession.ts:95

Parameters
ParameterType
responseMode?ResponseMode
Returns

boolean

lastError
lastError: Error | null;

Defined in: react/useDelphiSession.ts:77

listen
listen: (options: SessionListenOptions) => boolean;

Defined in: react/useDelphiSession.ts:94

Parameters
ParameterType
optionsSessionListenOptions
Returns

boolean

messages
messages: ChannelMessage[];

Defined in: react/useDelphiSession.ts:76

sendActionProgress
sendActionProgress: (actionId: string, status: 'received' | 'executing') => boolean;

Defined in: react/useDelphiSession.ts:103

Parameters
ParameterType
actionIdstring
status"received" | "executing"
Returns

boolean

sendActionUpdateChat
sendActionUpdateChat: (actionId: string, content: string, metadata?: Record<string, unknown>) =>
boolean;

Defined in: react/useDelphiSession.ts:104

Parameters
ParameterType
actionIdstring
contentstring
metadata?Record<string, unknown>
Returns

boolean

sendAsyncActionResult
sendAsyncActionResult: (
actionId: string,
success: boolean,
options?: {
data?: unknown;
durationMs?: number;
error?: string;
},
) => boolean;

Defined in: react/useDelphiSession.ts:98

Parameters
ParameterType
actionIdstring
successboolean
options?{ data?: unknown; durationMs?: number; error?: string; }
options.data?unknown
options.durationMs?number
options.error?string
Returns

boolean

sendBrowserAction
sendBrowserAction: (payload: BrowserActionPayload) => boolean;

Defined in: react/useDelphiSession.ts:93

Parameters
ParameterType
payloadBrowserActionPayload
Returns

boolean

sendChat
sendChat: (
content: string,
options?: {
intent?:
| 'conversation'
| 'notification'
| 'context_update'
| 'browser_context'
| 'action_update'
| 'read_aloud';
metadata?: Record<string, unknown>;
preferredResponse?: ResponseMode;
responseExpected?: boolean;
},
) => boolean;

Defined in: react/useDelphiSession.ts:79

Parameters
ParameterType
contentstring
options?{ intent?: | "conversation" | "notification" | "context_update" | "browser_context" | "action_update" | "read_aloud"; metadata?: Record<string, unknown>; preferredResponse?: ResponseMode; responseExpected?: boolean; }
options.intent?| "conversation" | "notification" | "context_update" | "browser_context" | "action_update" | "read_aloud"
options.metadata?Record<string, unknown>
options.preferredResponse?ResponseMode
options.responseExpected?boolean
Returns

boolean

sendContextUpdate
sendContextUpdate: (content: string, metadata?: Record<string, unknown>) => boolean;

Defined in: react/useDelphiSession.ts:88

Parameters
ParameterType
contentstring
metadata?Record<string, unknown>
Returns

boolean

sendMessage
sendMessage: (message: Partial<ChannelMessage>) => boolean;

Defined in: react/useDelphiSession.ts:109

Parameters
ParameterType
messagePartial<ChannelMessage>
Returns

boolean

sendReadAloud
sendReadAloud: (content: string, metadata?: Record<string, unknown>) => boolean;

Defined in: react/useDelphiSession.ts:92

Parameters
ParameterType
contentstring
metadata?Record<string, unknown>
Returns

boolean

sendTextChat
sendTextChat: (content: string, metadata?: Record<string, unknown>) => boolean;

Defined in: react/useDelphiSession.ts:91

Parameters
ParameterType
contentstring
metadata?Record<string, unknown>
Returns

boolean

serverReady
serverReady: boolean;

Defined in: react/useDelphiSession.ts:73

True once TelAPI has acknowledged and prepared the session channel.

session
session: SessionClient | null;

Defined in: react/useDelphiSession.ts:69

The underlying session, or null while the hook is opening / idle.

sessionId
sessionId: string | null;

Defined in: react/useDelphiSession.ts:74

setBrowserContext
setBrowserContext: (browserContext: BrowserContext) => boolean;

Defined in: react/useDelphiSession.ts:89

Parameters
ParameterType
browserContextBrowserContext
Returns

boolean

setResponseMode
setResponseMode: (responseMode: ResponseMode) => boolean;

Defined in: react/useDelphiSession.ts:97

Parameters
ParameterType
responseModeResponseMode
Returns

boolean

setSelectionContext
setSelectionContext: (selection: BrowserContext) => boolean;

Defined in: react/useDelphiSession.ts:90

Parameters
ParameterType
selectionBrowserContext
Returns

boolean

textChatEnabled
textChatEnabled: boolean;

Defined in: react/useDelphiSession.ts:75

Functions

DelphiClientProvider()

function DelphiClientProvider(__namedParameters: DelphiClientProviderProps): Element;

Defined in: react/context.tsx:39

Provides a DelphiClient instance to the React tree.

Mount this once at the root (or around the part of the tree that needs the phone). The client is created on mount, kept stable across re-renders (even if config changes reference), and destroyed on unmount.

Parameters

ParameterType
__namedParametersDelphiClientProviderProps

Returns

Element

Example

<DelphiClientProvider config={{apiDomain, apiKey}}>
<App />
</DelphiClientProvider>

DelphiConfigInit()

function DelphiConfigInit(__namedParameters: {config: DelphiConfig}): null;

Defined in: react/DelphiConfigInit.tsx:26

Syncs config into the nearest DelphiClient from context.

This is a zero-render component — place it once near the root of your authenticated layout. It must be a descendant of <DelphiClientProvider>.

Useful when the config (e.g. apiKey) is only available after the user has authenticated, so it cannot be passed to the provider directly.

Parameters

ParameterType
__namedParameters{ config: DelphiConfig; }
__namedParameters.configDelphiConfig

Returns

null

Example

<DelphiClientProvider>
<DelphiConfigInit config={config} />
<App />
</DelphiClientProvider>

useBrowserAction()

function useBrowserAction(
optionsOrNavigate?: ExecuteBrowserActionOptions | NavigateCallback,
): (action: ActionPayload) => Promise<ActionResult>;

Defined in: react/useBrowserAction.ts:23

Returns a stable onAction callback that delegates browser-action execution to executeBrowserAction from the headless core.

Pass the returned handler directly to a SessionClient's onAction option or to useDelphiSession({ onAction }).

Parameters

ParameterType
optionsOrNavigate?| ExecuteBrowserActionOptions | NavigateCallback

Returns

(action: ActionPayload) => Promise<ActionResult>

Example

const handleBrowserAction = useBrowserAction(router.push);
const {session} = useDelphiSession({
endpointId,
mode: 'voice_conversation',
onAction: handleBrowserAction,
});

useDelphiClient()

function useDelphiClient(config: DelphiConfig): {
client: DelphiClient;
state: Readonly<DelphiClientState>;
};

Defined in: react/useDelphiClient.ts:54

Creates and manages a DelphiClient instance scoped to the calling component. Use this when you don't want a context provider (e.g. self-contained phone widget).

The client is created once (ref-stable across StrictMode) and destroyed on unmount.

Parameters

ParameterType
configDelphiConfig

Returns

{
client: DelphiClient;
state: Readonly<DelphiClientState>;
}
client
client: DelphiClient;
state
state: Readonly<DelphiClientState>;

Example

function PhoneWidget() {
const {state, client} = useDelphiClient({apiDomain, apiKey});
// ...
}

useDelphiClientContext()

function useDelphiClientContext(): DelphiClient;

Defined in: react/context.tsx:74

Returns the nearest DelphiClient from context. Must be used inside <DelphiClientProvider>.

Returns

DelphiClient


useDelphiClientState()

function useDelphiClientState(): {
client: DelphiClient;
state: Readonly<DelphiClientState>;
};

Defined in: react/useDelphiClient.ts:25

Subscribes to the DelphiClient provided by <DelphiClientProvider> and returns the current state + the client instance.

Returns

{
client: DelphiClient;
state: Readonly<DelphiClientState>;
}
client
client: DelphiClient;
state
state: Readonly<DelphiClientState>;

Example

const {state, client} = useDelphiClientState();
return <button onClick={() => client.startCall({endpointId: 'ep_1'})}>Call</button>;

useDelphiSession()

function useDelphiSession(options: UseDelphiSessionOptions): UseDelphiSessionReturn;

Defined in: react/useDelphiSession.ts:163

React hook that opens (or reuses) a SessionClient for an endpoint.

Sessions are find-or-create per endpointId on the parent DelphiClient, so multiple components asking for the same endpoint share one WebSocket.

Parameters

ParameterType
optionsUseDelphiSessionOptions

Returns

UseDelphiSessionReturn

Example

const {session, connected, sendReadAloud} = useDelphiSession({
endpointId: 'ext-100',
mode: 'audio_playback',
onAction: handleBrowserAction,
});

// Or just use the orchestrator directly for one-shot reads:
await delphi.readAloud('Hello!', {endpointId: 'ext-100'});

useSelectionTracking()

function useSelectionTracking(sendReadAloud: {
channelConnected: boolean;
forceEnable?: boolean;
sendReadAloud: (text: string) => void;
}): {
handleReadAloudSelected: () => void;
selectedText: string;
showReadAloudFab: boolean;
};

Defined in: react/useSelectionTracking.ts:41

Tracks text selection on the page and exposes a handler to send the selected text as a "read aloud" request to the AI.

Requires a <DelphiClientProvider> in the tree.

Parameters

ParameterTypeDescription
sendReadAloud{ channelConnected: boolean; forceEnable?: boolean; sendReadAloud: (text: string) => void; }Callback to send selected text (e.g. from useDelphiSession().sendReadAloud).
sendReadAloud.channelConnectedboolean-
sendReadAloud.forceEnable?boolean-
sendReadAloud.sendReadAloud(text: string) => void-

Returns

{
handleReadAloudSelected: () => void;
selectedText: string;
showReadAloudFab: boolean;
}
handleReadAloudSelected
handleReadAloudSelected: () => void;
Returns

void

selectedText
selectedText: string;
showReadAloudFab
showReadAloudFab: boolean;

Example

const {session, sendReadAloud, connected} = useDelphiSession({
endpointId: 'ext-100',
mode: 'audio_playback',
});
const {selectedText, handleReadAloudSelected, showReadAloudFab} = useSelectionTracking({
sendReadAloud,
channelConnected: connected,
forceEnable: true,
});

References

ActionHandler

Re-exports ActionHandler


ActionPayload

Re-exports ActionPayload


ActionResult

Re-exports ActionResult


AsyncActionResult

Re-exports AsyncActionResult


AudioPayload

Re-exports AudioPayload


BrowserActionHandler

Re-exports BrowserActionHandler


BrowserActionPayload

Re-exports BrowserActionPayload


BrowserAudioEvent

Re-exports BrowserAudioEvent


BrowserContext

Re-exports BrowserContext


BrowserSelectionContext

Re-exports BrowserSelectionContext


ChannelMessage

Re-exports ChannelMessage


ChatPayload

Re-exports ChatPayload


ControlPayload

Re-exports ControlPayload


DelphiClientState

Re-exports DelphiClientState


DelphiConfig

Re-exports DelphiConfig


DelphiPhoneProps

Re-exports DelphiPhoneProps


ExecuteBrowserActionOptions

Re-exports ExecuteBrowserActionOptions


IceServer

Re-exports IceServer


ListenOptions

Re-exports ListenOptions


Logger

Re-exports Logger


MessageHandler

Re-exports MessageHandler


OpenSessionOptions

Re-exports OpenSessionOptions


PersistedSessionState

Re-exports PersistedSessionState


ReadAloudOptions

Re-exports ReadAloudOptions


ResponseMode

Re-exports ResponseMode


SessionConnectionState

Re-exports SessionConnectionState


SessionListenOptions

Re-exports SessionListenOptions


SessionMode

Re-exports SessionMode


SessionTokenResponse

Re-exports SessionTokenResponse


StartCallOptions

Re-exports StartCallOptions


StatusPayload

Re-exports StatusPayload


SyncActionResult

Re-exports SyncActionResult