createTalkitCall
Create and control a TalkIt Website voice-call client in the browser.
On this page
Use createTalkitCall with a callback that obtains a fresh, short-lived Website session grant for every connection attempt.
Package provenance
Generated from @talkit-llc/talkit-js@0.1.12, entrypoint ..
Download the TypeScript declaration snapshot
createTalkitCall
Creates a voice-call client from the supplied transport and grant configuration.
declare function createTalkitCall(config: TalkitCallConfig): TalkitCall;
TalkitCallConfig
Configures the TalkIt server, session-grant callback, worklet override, and startup timeout.
interface TalkitCallConfig {
baseUrl: string;
getSessionToken: () => Promise<string | TalkitCallSessionTokenResult>;
workletUrl?: string;
startupTimeoutMs?: number;
}
TalkitCallSessionTokenResult
Describes the grant returned by the session-token callback.
interface TalkitCallSessionTokenResult {
sessionToken: string;
websocketUrl?: string;
expiresAt?: string;
}
TalkitCall
Exposes call lifecycle controls and typed event subscriptions.
interface TalkitCall {
start(): Promise<void>;
stop(): void;
interrupt(): void;
mute(nextMuted?: boolean): boolean;
destroy(): void;
on<TEventName extends TalkitCallEventName>(eventName: TEventName, handler: TalkitCallEventHandler<TEventName>): void;
off<TEventName extends TalkitCallEventName>(eventName: TEventName, handler: TalkitCallEventHandler<TEventName>): void;
}
TalkitCallEventName
Union of the supported call event names.
type TalkitCallEventName = keyof TalkitCallEventMap;
TalkitCallEventHandler
Typed callback for one call event.
type TalkitCallEventHandler<TEventName extends TalkitCallEventName> = (event: TalkitCallEventMap[TEventName]) => void;
TalkitCallEventMap
Maps every supported call event name to its payload type.
interface TalkitCallEventMap {
connecting: TalkitCallLifecycleEvent;
connected: TalkitCallLifecycleEvent;
ready: TalkitCallLifecycleEvent;
speaking: TalkitCallLifecycleEvent;
listening: TalkitCallLifecycleEvent;
ended: TalkitCallEndedEvent;
error: TalkitCallErrorEvent;
state: TalkitCallStateEvent;
debug: TalkitCallDebugEvent;
}
TalkitCallLifecycleEvent
Common lifecycle payload that may identify the call and conversation group.
interface TalkitCallLifecycleEvent {
callId?: string;
conversationGroupKey?: string;
}
TalkitCallStateEvent
Reports the current call state and optional server command.
interface TalkitCallStateEvent {
callId?: string;
state: 'idle' | 'connecting' | 'connected' | 'ready' | 'speaking' | 'listening' | 'ended';
command?: TalkitCallCommand;
}
TalkitCallCommand
Known server commands while preserving forward compatibility with additional command strings.
type TalkitCallCommand = 'INTERRUPT' | 'PAUSE' | 'RESUME' | 'DUCK_OUTPUT' | 'RESET_OUTPUT_VOLUME' | (string & {});
TalkitCallEndedEvent
Reports the call identifier and optional termination reason.
interface TalkitCallEndedEvent {
callId?: string;
reason?: string;
}
TalkitCallErrorEvent
Reports a call error code and message.
interface TalkitCallErrorEvent {
code?: string;
message: string;
}
TalkitCallDebugEvent
Carries diagnostic call events for development and support.
interface TalkitCallDebugEvent {
type: string;
sequence?: number;
callId?: string;
occurredAt?: number;
[key: string]: unknown;
}