Appearance
Complete Event Reference
Complete reference for all events in the SDK.
Base Event Structure
All events extend the base event structure:
typescript
interface BaseEvent {
session: {
id: string; // UUID of the session
account_id: string; // Account identifier
phone_number: string; // Phone number for this flow session
direction?: "inbound" | "outbound"; // Call direction
from_phone_number: string; // Phone number of the caller
to_phone_number: string; // Phone number of the callee
};
}All Event Types
| Event Type | Description | When Triggered |
|---|---|---|
session_start | Call session begins | When a new call is initiated |
user_speak | User speech detected | After speech-to-text completes (includes barged_in flag) |
assistant_speak | Assistant finished speaking | After TTS playback completes |
assistant_speech_ended | Assistant finished speaking | After speech playback ends |
session_end | Call session ends | When the call terminates |
Event Type Definitions
session_start
typescript
interface AiFlowEventSessionStart {
type: "session_start";
session: {
id: string;
account_id: string;
phone_number: string; // Phone number for this flow session
direction?: "inbound" | "outbound"; // Call direction
from_phone_number: string;
to_phone_number: string;
};
}user_speak
typescript
interface AiFlowEventUserSpeak {
type: "user_speak";
text: string; // Recognized speech text
barged_in?: boolean; // true if user interrupted assistant
session: SessionInfo;
}The barged_in flag is set to true when the user interrupts the assistant mid-speech.
assistant_speak
typescript
interface AiFlowEventAssistantSpeak {
type: "assistant_speak";
text?: string; // Text that was spoken
ssml?: string; // SSML that was used (if applicable)
duration_ms: number; // Duration of speech in milliseconds
speech_started_at: number; // Unix timestamp (ms) when speech started
session: SessionInfo;
}assistant_speech_ended
typescript
interface AiFlowEventAssistantSpeechEnded {
type: "assistant_speech_ended";
session: SessionInfo;
}session_end
typescript
interface AiFlowEventSessionEnd {
type: "session_end";
session: SessionInfo;
}Type Safety
All events are fully typed. Import types from the SDK:
typescript
import type {
AiFlowEventSessionStart,
AiFlowEventUserSpeak,
AiFlowEventAssistantSpeak,
AiFlowEventAssistantSpeechEnded,
AiFlowEventSessionEnd,
} from "@sipgate/ai-flow-sdk";Next Steps
- Complete Action Reference - All action types
- Direct Integration - Working without the wrapper