Skip to documentation content
Docs
Documentation navigation
Reference
6 min read

createTalkitCall

Create and control a TalkIt Website voice-call client in the browser.

UpdatedByTalkIt Docs team
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.

TS
declare function createTalkitCall(config: TalkitCallConfig): TalkitCall;

TalkitCallConfig

Configures the TalkIt server, session-grant callback, worklet override, and startup timeout.

TS
interface TalkitCallConfig {
    baseUrl: string;
    getSessionToken: () => Promise<string | TalkitCallSessionTokenResult>;
    workletUrl?: string;
    startupTimeoutMs?: number;
}

TalkitCallSessionTokenResult

Describes the grant returned by the session-token callback.

TS
interface TalkitCallSessionTokenResult {
    sessionToken: string;
    websocketUrl?: string;
    expiresAt?: string;
}

TalkitCall

Exposes call lifecycle controls and typed event subscriptions.

TS
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.

TS
type TalkitCallEventName = keyof TalkitCallEventMap;

TalkitCallEventHandler

Typed callback for one call event.

TS
type TalkitCallEventHandler<TEventName extends TalkitCallEventName> = (event: TalkitCallEventMap[TEventName]) => void;

TalkitCallEventMap

Maps every supported call event name to its payload type.

TS
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.

TS
interface TalkitCallLifecycleEvent {
    callId?: string;
    conversationGroupKey?: string;
}

TalkitCallStateEvent

Reports the current call state and optional server command.

TS
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.

TS
type TalkitCallCommand = 'INTERRUPT' | 'PAUSE' | 'RESUME' | 'DUCK_OUTPUT' | 'RESET_OUTPUT_VOLUME' | (string & {});

TalkitCallEndedEvent

Reports the call identifier and optional termination reason.

TS
interface TalkitCallEndedEvent {
    callId?: string;
    reason?: string;
}

TalkitCallErrorEvent

Reports a call error code and message.

TS
interface TalkitCallErrorEvent {
    code?: string;
    message: string;
}

TalkitCallDebugEvent

Carries diagnostic call events for development and support.

TS
interface TalkitCallDebugEvent {
    type: string;
    sequence?: number;
    callId?: string;
    occurredAt?: number;
    [key: string]: unknown;
}

Was this page helpful?

Page feedback is not available right now.