Skip to content

Complete Action Reference

Complete reference for all actions in the SDK.

Base Action Structure

All actions require a session_id and type field:

typescript
interface BaseAction {
  session_id: string; // UUID from the event's session.id
  type: string;        // Action type identifier
}

All Action Types

Action TypeDescriptionPrimary Use Case
speakSpeak text or SSMLRespond to user with synthesized speech
audioPlay pre-recorded audioPlay hold music, pre-recorded messages
hangupEnd the callTerminate conversation
transferTransfer to another numberRoute to human agent or department
barge_inManually interrupt playbackStop current audio immediately

Action Type Definitions

speak - Text-to-speech response

typescript
interface AiFlowActionSpeak {
  type: "speak";
  session_id: string;

  // Provide either text OR ssml (not both)
  text?: string;
  ssml?: string;

  // Optional TTS configuration
  tts?: {
    provider: "azure";
    language?: string; // e.g., "en-US", "de-DE"
    voice?: string;    // Azure voice name
  } | {
    provider: "eleven_labs";
    voice?: string;    // ElevenLabs voice ID (optional, uses default if omitted)
  };

  barge_in?: {
    strategy: "none" | "manual" | "minimum_characters";
    minimum_characters?: number; // Default: 3
    allow_after_ms?: number;     // Delay before allowing interruption
  };
}

audio - Play pre-recorded audio

typescript
interface AiFlowActionAudio {
  type: "audio";
  session_id: string;
  audio: string; // Base64 encoded WAV (16kHz, mono, 16-bit PCM)

  barge_in?: {
    strategy: "none" | "manual" | "minimum_characters";
    minimum_characters?: number;
    allow_after_ms?: number;
  };
}

hangup - End call

typescript
interface AiFlowActionHangup {
  type: "hangup";
  session_id: string;
}

transfer - Transfer call

typescript
interface AiFlowActionTransfer {
  type: "transfer";
  session_id: string;
  target_phone_number: string; // E.164 format recommended
  caller_id_name: string;
  caller_id_number: string;
}

barge_in - Manual interrupt

typescript
interface AiFlowActionBargeIn {
  type: "barge_in";
  session_id: string;
}

Type Safety

All actions are fully typed. Import types from the SDK:

typescript
import type {
  AiFlowAction,
  AiFlowActionSpeak,
  AiFlowActionAudio,
  AiFlowActionHangup,
  AiFlowActionTransfer,
  AiFlowActionBargeIn,
} from "@sipgate/ai-flow-sdk";

Next Steps