SignalWire AI Developer Platform: Complete Guide πŸ”— ↑ TOC

Understanding SWML, AI Agents, and SWAIG

Table of Contents πŸ”— ↑ TOC

  1. Executive Summary
  2. Platform Architecture Overview
  3. SignalWire Markup Language (SWML)
  4. AI Agent System
  5. SignalWire AI Gateway (SWAIG)
  6. The Prompt Object Model (POM)
  7. Real-Time Communication Foundation
  8. Developer Experience and SDK
  9. Security and Authentication
  10. Performance and Scale
  11. Real-World Applications
  12. Getting Started

Executive Summary πŸ”— ↑ TOC

SignalWire AI represents a paradigm shift in conversational AI infrastructure, arriving at a critical inflection point in communications technology. Built on SignalWire's battle-tested telecommunications platform, it provides the only complete solution that unifies real-time communication protocols with advanced AI capabilities.

The AI Transformation Imperative πŸ”— ↑ TOC

We are experiencing the first re-engineering of global voice platforms in over 15 years, driven by several converging forces:

SignalWire: The Voice Pipes for AI πŸ”— ↑ TOC

SignalWire AI serves as the universal voice pipes for any form of AI communication, providing:

Key Differentiators:

  1. Native Protocol Support: Direct implementation of SIP, WebRTC, and PSTN protocols
  2. Real-Time Media Processing: Hardware-accelerated audio/video processing with sub-100ms latency
  3. Global Reach: Data centers around the world
  4. Codec Agnostic: Support for all major audio/video codecs (Opus, G.722, H.264, VP8, etc.)
  5. AI-First Design: Every component optimized for conversational AI workloads

Platform Architecture Overview πŸ”— ↑ TOC

The Full Stack Advantage πŸ”— ↑ TOC

SignalWire AI operates on a vertically integrated architecture that spans from hardware-level telecom infrastructure to high-level AI abstractions:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  Developer Layer                        β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚  β”‚   Python    β”‚  β”‚    SWML     β”‚  β”‚   SWAIG     β”‚    β”‚
β”‚  β”‚     SDK     β”‚  β”‚  Documents  β”‚  β”‚ Functions   β”‚    β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                  AI Orchestration                       β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚  β”‚ Conversationβ”‚  β”‚   Function  β”‚  β”‚   State     β”‚    β”‚
β”‚  β”‚   Manager   β”‚  β”‚  Executor   β”‚  β”‚   Manager   β”‚    β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                 Media Processing                        β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚  β”‚   Speech    β”‚  β”‚    Text     β”‚  β”‚   Video     β”‚    β”‚
β”‚  β”‚ Recognition β”‚  β”‚ to Speech   β”‚  β”‚ Processing  β”‚    β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚              Protocol & Transport                       β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚  β”‚     SIP     β”‚  β”‚   WebRTC    β”‚  β”‚    PSTN     β”‚    β”‚
β”‚  β”‚  Protocol   β”‚  β”‚  Transport  β”‚  β”‚ Connectivityβ”‚    β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚               Global Infrastructure                     β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚  β”‚   Regional  β”‚  β”‚   Carrier   β”‚  β”‚   Edge      β”‚    β”‚
β”‚  β”‚    Data     β”‚  β”‚ Relations   β”‚  β”‚  Presence   β”‚    β”‚
β”‚  β”‚   Centers   β”‚  β”‚             β”‚  β”‚             β”‚    β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Key Differentiators πŸ”— ↑ TOC

  1. Native Protocol Support: Direct implementation of SIP, WebRTC, and PSTN protocols
  2. Real-Time Media Processing: Hardware-accelerated audio/video processing with sub-100ms latency
  3. Global Reach: Data centers around the world
  4. Codec Agnostic: Support for all major audio/video codecs (Opus, G.722, H.264, VP8, etc.)
  5. AI-First Design: Every component optimized for conversational AI workloads

FreeSWITCH Foundation: Proven at Scale πŸ”— ↑ TOC

SignalWire's architecture is built upon FreeSWITCH, the open-source telephony platform that powers 95% of the cloud communications industry. This foundation provides:

Programmable Unified Communications (PUC) πŸ”— ↑ TOC

SignalWire has created a category in the communications space called PUC (Programmable Unified Communications) - a cloud replacement for local VoIP infrastructure and services that makes communication programmable, composable, and easy to manage.

Call Fabric: PUC Implementation πŸ”— ↑ TOC

Call Fabric is SignalWire's implementation of Programmable Unified Communications, providing the foundation for building communications solutions through composable resources.

Composable Resources πŸ”— ↑ TOC

SignalWire introduces composable telecom infrastructure where every element is modular and reusable:

Resource-Based Architecture πŸ”— ↑ TOC

SWML scripts, Subscribers, AI Agents, and Rooms are resources in SignalWire that enable a resource model similar to familiar Internet components. Clients connect to Resources via Addresses, making applications available at scale.

Dynamic Composition πŸ”— ↑ TOC

When resources are composed, you can use APIs to interact with callers and build custom solutions:

Cloud-Agnostic Global Infrastructure πŸ”— ↑ TOC

SignalWire's infrastructure spans 48 worldwide Points of Presence (POPs) with cloud-agnostic architecture:

Global Telecom Infrastructure πŸ”— ↑ TOC

SignalWire operates a massive global telecommunications infrastructure that includes:

Physical Infrastructure πŸ”— ↑ TOC

Data Sovereignty & Compliance πŸ”— ↑ TOC

Protocol Support πŸ”— ↑ TOC

Codec Excellence πŸ”— ↑ TOC

Audio Codecs:
β”œβ”€β”€ Opus (48kHz, variable bitrate)
β”œβ”€β”€ G.722 (16kHz wideband)
β”œβ”€β”€ G.711 (8kHz, ΞΌ-law/A-law)
β”œβ”€β”€ G.729 (8kHz, compressed)
└── AMR-WB (adaptive multi-rate)

Video Codecs:
β”œβ”€β”€ VP8/VP9 (WebRTC standard)
β”œβ”€β”€ H.264 (universal compatibility)
β”œβ”€β”€ H.265/HEVC (next-generation)
└── AV1 (open standard)

Media Processing Pipeline πŸ”— ↑ TOC

The real-time media processing pipeline operates with strict latency requirements:

  1. Media Ingestion: Sub-10ms capture from various sources
  2. Protocol Translation: Seamless conversion between protocols
  3. Quality Enhancement: Noise reduction and echo cancellation
  4. AI Processing: Real-time speech recognition and synthesis
  5. Media Delivery: Optimized routing to endpoints

Quality Metrics πŸ”— ↑ TOC

SignalWire maintains carrier-grade quality standards:


SignalWire Markup Language (SWML) πŸ”— ↑ TOC

What is SWML? πŸ”— ↑ TOC

SWML is a declarative JSON-based markup language designed specifically for defining AI agent behavior in real-time communication scenarios. Unlike traditional APIs that require imperative programming, SWML allows developers to describe what they want the AI to do rather than how to do it.

Core SWML Structure πŸ”— ↑ TOC

Every SWML document follows this fundamental structure:

{
  "version": "1.0.0",
  "sections": {
    "main": [
      {
        "ai": {
          "prompt": {
            "text": "You are a helpful assistant..."
          },
          "post_prompt": {
            "text": "Summarize the conversation..."
          },
          "params": {
            "temperature": 0.7,
            "max_tokens": 1000
          }
        }
      }
    ]
  }
}

The AI Verb πŸ”— ↑ TOC

The ai verb is the primary building block for conversational AI in SWML. It configures:

Example AI verb with advanced configuration:

{
  "ai": {
    "prompt": {
      "text": "You are a customer service representative for Acme Corp."
    },
    "params": {
      "temperature": 0.3,
      "max_tokens": 500,
      "end_of_speech_timeout": 300
    },
    "languages": [
      {
        "name": "English",
        "code": "en-US",
        "voice": "elevenlabs.rachel"
      }
    ],
    "SWAIG": {
      "functions": [
        {
          "function": "check_order_status",
          "description": "Check the status of a customer order",
          "parameters": {
            "type": "object",
            "properties": {
              "order_id": {
                "type": "string",
                "description": "The order ID to check"
              }
            },
            "required": ["order_id"]
          }
        }
      ]
    }
  }
}

SWML Execution Model πŸ”— ↑ TOC

SWML documents are executed by the SignalWire AI engine using a sophisticated state machine:

  1. Document Loading: SWML is parsed and validated
  2. Section Execution: Sections execute sequentially by default
  3. Verb Processing: Each verb (ai, play, record, etc.) is processed
  4. Event Handling: Real-time events trigger state transitions
  5. Function Calls: SWAIG functions execute asynchronously
  6. Cleanup: Resources are managed automatically

Advanced SWML Features πŸ”— ↑ TOC

Conditional Logic πŸ”— ↑ TOC

{
  "switch": {
    "variable": "customer_tier",
    "case": {
      "premium": [
        {"ai": {"prompt": "VIP greeting for premium customers"}}
      ],
      "standard": [
        {"ai": {"prompt": "Standard greeting"}}
      ]
    }
  }
}

Loop Constructs πŸ”— ↑ TOC

{
  "loop": {
    "count": 3,
    "do": [
      {"ai": {"prompt": "Please provide your account number"}},
      {"input": {"max_digits": 10, "timeout": 30}}
    ]
  }
}

Variable Management πŸ”— ↑ TOC

{
  "set": {
    "customer_id": "12345",
    "call_timestamp": "${now()}"
  }
}

AI Agent System πŸ”— ↑ TOC

Embedded AI Kernel Architecture πŸ”— ↑ TOC

SignalWire's AI Agent system is fundamentally different from traditional AI platforms. Instead of bolting AI capabilities onto existing communication infrastructure, SignalWire embeds the AI kernel directly into the media stack.

No-Detours Design Philosophy πŸ”— ↑ TOC

Voice, transcription, memory, and LLM reasoning run inside the media layer - no detours.

Traditional AI communication systems suffer from architectural inefficiencies:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Audio     │───▢│ Transcription│───▢│   AI API    │───▢│  Text-to-    β”‚
β”‚  Stream     β”‚    β”‚   Service    β”‚    β”‚   Call      β”‚    β”‚   Speech     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
     Network hop      Network hop         Network hop         Network hop

SignalWire's embedded approach eliminates these hops:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    SignalWire Media Stack                               β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚   Audio     │─── Transcriptionβ”œβ”€β”€β”€ AI Reasoningβ”œβ”€β”€β”€ Text-to-Speechβ”‚ β”‚
β”‚  β”‚  Stream     β”‚  β”‚   Engine     β”‚  β”‚   Engine    β”‚  β”‚    Engine    β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        Single memory space

Agent Architecture πŸ”— ↑ TOC

The AI Agent system is built around a conversation-centric architecture that manages:

Conversation Management πŸ”— ↑ TOC

The conversation manager maintains sophisticated state across multiple dimensions:

Message History πŸ”— ↑ TOC

conversation_context = {
    "messages": [
        {"role": "system", "content": "You are a helpful assistant"},
        {"role": "user", "content": "What's the weather like?"},
        {"role": "assistant", "content": "I'll check the weather for you"},
        {"role": "function", "name": "get_weather", "content": "72Β°F, sunny"}
    ],
    "metadata": {
        "turn_count": 2,
        "function_calls": 1,
        "start_time": "2024-01-15T10:30:00Z"
    }
}

Context Windows πŸ”— ↑ TOC

The system automatically manages context windows, employing strategies like:

Function Call Management πŸ”— ↑ TOC

The AI system prevents common issues like:

Multi-Modal Capabilities πŸ”— ↑ TOC

The AI system supports multiple input and output modalities:

Audio Processing πŸ”— ↑ TOC

Video Processing πŸ”— ↑ TOC

Text Processing πŸ”— ↑ TOC


SignalWire AI Gateway (SWAIG) πŸ”— ↑ TOC

What is SWAIG? πŸ”— ↑ TOC

SWAIG (SignalWire AI Gateway) is SignalWire's production-ready equivalent of the Model Context Protocol (MCP). It serves as a secure, high-performance interface that allows AI agents to call external functions and services, and has been in stable production use for over a year.

SWAIG provides:

SWAIG Function Definition πŸ”— ↑ TOC

Functions are defined using a JSON Schema-based format:

{
  "function": "get_customer_balance",
  "description": "Retrieve current account balance for a customer",
  "parameters": {
    "type": "object",
    "properties": {
      "customer_id": {
        "type": "string",
        "description": "Unique customer identifier"
      },
      "account_type": {
        "type": "string",
        "enum": ["checking", "savings", "credit"],
        "description": "Type of account to check"
      }
    },
    "required": ["customer_id"]
  },
  "web_hook_url": "https://mybank.com/api/balance",
  "web_hook_auth_user": "api_user",
  "web_hook_auth_password": "secure_password"
}

Function Execution Flow πŸ”— ↑ TOC

When an AI agent needs to call a function:

  1. Intent Recognition: The AI determines a function call is needed
  2. Parameter Extraction: Arguments are extracted from conversation context
  3. Security Validation: Tokens and permissions are verified
  4. HTTP Request: A POST request is made to the webhook URL
  5. Response Processing: Results are integrated back into the conversation
  6. Continuation: The AI continues with the new information

Request/Response Format πŸ”— ↑ TOC

SWAIG Request πŸ”— ↑ TOC

{
  "function": "get_customer_balance",
  "argument": {
    "parsed": [{"customer_id": "12345", "account_type": "checking"}],
    "raw": "{\"customer_id\":\"12345\",\"account_type\":\"checking\"}"
  },
  "call_id": "abc-123-def",
  "ai_session_id": "session-456",
  "conversation_id": "conv-789",
  "caller_id_name": "John Doe",
  "caller_id_num": "+15551234567",
  "project_id": "proj-123",
  "space_id": "space-456"
}

SWAIG Response πŸ”— ↑ TOC

{
  "response": "The checking account balance is $1,247.83",
  "action": [
    {
      "say": "Your current checking account balance is $1,247.83"
    }
  ]
}

Advanced SWAIG Features πŸ”— ↑ TOC

Function Chaining πŸ”— ↑ TOC

{
  "response": "Found customer information",
  "action": [
    {
      "toggle_functions": [
        {"function": "basic_lookup", "active": false},
        {"function": "detailed_lookup", "active": true}
      ]
    }
  ]
}

State Management πŸ”— ↑ TOC

{
  "response": "Customer verified",
  "action": [
    {
      "set": {
        "customer_verified": true,
        "verification_timestamp": "${now()}"
      }
    }
  ]
}

SWML Injection πŸ”— ↑ TOC

{
  "response": "Transferring to specialist",
  "action": [
    {
      "SWML": {
        "version": "1.0.0",
        "sections": {
          "main": [
            {"transfer": {"to": "+15551234567"}}
          ]
        }
      }
    }
  ]
}

The Prompt Object Model (POM) πŸ”— ↑ TOC

What is POM? πŸ”— ↑ TOC

The Prompt Object Model is SignalWire's structured approach to AI prompt management. Instead of simple text prompts, POM allows complex, multi-section prompts that can include:

POM Structure πŸ”— ↑ TOC

{
  "prompt": {
    "pom": [
      {
        "role": "system",
        "content": {
          "type": "text",
          "text": "You are a ${role} for ${company}"
        }
      },
      {
        "role": "user", 
        "content": [
          {
            "type": "text",
            "text": "Help me with ${task}"
          },
          {
            "type": "audio",
            "url": "https://example.com/context.wav"
          }
        ]
      }
    ]
  }
}

Dynamic Prompt Variables πŸ”— ↑ TOC

POM supports real-time variable substitution:

{
  "prompt": "You are helping ${customer_name} (ID: ${customer_id}) who called at ${call_time}. Their account status is ${account_status}."
}

Variables can be: - Static: Set at agent initialization - Dynamic: Updated during conversation - Computed: Calculated from functions or system state - Contextual: Derived from conversation history

Multi-Modal Prompts πŸ”— ↑ TOC

POM supports different prompt formats for different AI models:

{
  "prompt": {
    "text": "You are a helpful assistant",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant"},
      {"role": "user", "content": "Hello"}
    ],
    "vision": {
      "system": "You can see and describe images",
      "image_url": "https://example.com/image.jpg"
    }
  }
}

Real-Time Communication Foundation πŸ”— ↑ TOC

Global Telecom Infrastructure πŸ”— ↑ TOC

SignalWire operates a massive global telecommunications infrastructure that includes:

Physical Infrastructure πŸ”— ↑ TOC

Data Sovereignty & Compliance πŸ”— ↑ TOC

Protocol Support πŸ”— ↑ TOC

Codec Excellence πŸ”— ↑ TOC

Audio Codecs:
β”œβ”€β”€ Opus (48kHz, variable bitrate)
β”œβ”€β”€ G.722 (16kHz wideband)
β”œβ”€β”€ G.711 (8kHz, ΞΌ-law/A-law)
β”œβ”€β”€ G.729 (8kHz, compressed)
└── AMR-WB (adaptive multi-rate)

Video Codecs:
β”œβ”€β”€ VP8/VP9 (WebRTC standard)
β”œβ”€β”€ H.264 (universal compatibility)
β”œβ”€β”€ H.265/HEVC (next-generation)
└── AV1 (open standard)

Media Processing Pipeline πŸ”— ↑ TOC

The real-time media processing pipeline operates with strict latency requirements:

  1. Media Ingestion: Sub-10ms capture from various sources
  2. Protocol Translation: Seamless conversion between protocols
  3. Quality Enhancement: Noise reduction and echo cancellation
  4. AI Processing: Real-time speech recognition and synthesis
  5. Media Delivery: Optimized routing to endpoints

Quality Metrics πŸ”— ↑ TOC

SignalWire maintains carrier-grade quality standards:


Developer Experience and SDK πŸ”— ↑ TOC

Stateless Call Control Revolution πŸ”— ↑ TOC

The SignalWire AI Python SDK fundamentally reimagines how developers control real-time communication. Instead of maintaining complex stateful connections, the SDK operates on a stateless client/server model where your Python code can dynamically control live calls through HTTP webhooks.

Real-Time Call Programming πŸ”— ↑ TOC

from signalwire_agents import AgentBase, SwaigFunctionResult

class CallControlAgent(AgentBase):
    def __init__(self):
        super().__init__(name="CallControl")

    @tool(name="transfer_to_specialist")
    def transfer_to_specialist(self, args, raw_data):
        department = args.get("department", "sales")

        # Dynamically control the live call
        if department == "billing":
            phone_number = "+15551234567"
        elif department == "technical":
            phone_number = "+15559876543"
        else:
            phone_number = "+15555555555"

        # Return SWML to execute call transfer
        return SwaigFunctionResult(
            f"Transferring you to {department}",
            action=[{
                "transfer": {
                    "to": phone_number,
                    "timeout": 30
                }
            }]
        )

    @tool(name="start_conference")
    def start_conference(self, args, raw_data):
        # Create conference and invite participants
        return SwaigFunctionResult(
            "Starting conference call",
            action=[{
                "conference": {
                    "name": f"meeting-{raw_data.get('call_id')}",
                    "participants": args.get("participants", [])
                }
            }]
        )

Composable Skills Architecture πŸ”— ↑ TOC

The SDK's Skills System transforms complex AI capabilities into reusable, composable building blocks:

Drop-in Capabilities πŸ”— ↑ TOC

class SuperAgent(AgentBase):
    def __init__(self):
        super().__init__(name="SuperAgent")

        # Add web search capability instantly
        self.add_skill("web_search", {
            "num_results": 5,
            "delay": 0.5  # Rate limiting
        })

        # Add datetime awareness
        self.add_skill("datetime")

        # Add mathematical computation
        self.add_skill("math")

        # Now your agent can search the web, handle dates, and do math
        # without writing any additional code

    def get_prompt(self):
        return """You are a research assistant with web search, 
        date/time awareness, and mathematical capabilities."""

Custom Skills Creation πŸ”— ↑ TOC

from signalwire_agents.core.skill_base import SkillBase

class DatabaseSkill(SkillBase):
    SKILL_NAME = "database_lookup"

    def execute(self, query: str, table: str):
        # Your custom database logic
        results = self.db.query(table, query)
        return f"Found {len(results)} results"

# Register and use your custom skill
agent.register_skill(DatabaseSkill())
agent.add_skill("database_lookup")

SWML Abstraction Layer πŸ”— ↑ TOC

The SDK completely abstracts away SWML complexity, letting you control sophisticated call flows with simple Python:

Dynamic Call Flow Control πŸ”— ↑ TOC

class DynamicFlowAgent(AgentBase):
    @tool(name="route_customer")
    def route_customer(self, args, raw_data):
        customer_tier = args.get("tier")
        issue_type = args.get("issue_type")

        # Complex routing logic in simple Python
        if customer_tier == "premium" and issue_type == "technical":
            return SwaigFunctionResult(
                "Connecting you to our senior technical team",
                action=[{
                    "connect": {
                        "to": "premium-tech-queue",
                        "music": "premium_hold_music"
                    }
                }]
            )
        elif issue_type == "billing":
            return SwaigFunctionResult(
                "Let me get your account details first",
                action=[{
                    "gather": {
                        "input": "speech",
                        "timeout": 10,
                        "hints": ["account number", "phone number"]
                    }
                }]
            )
        else:
            # Default to AI conversation
            return SwaigFunctionResult("How can I help you today?")

Advanced Abstractions πŸ”— ↑ TOC

DataMap Integration - API Calls Made Simple πŸ”— ↑ TOC

from signalwire_agents.core.data_map import DataMap

class CRMAgent(AgentBase):
    def __init__(self):
        super().__init__(name="CRMAgent")

        # Define complex API integration in a few lines
        customer_lookup = (DataMap('get_customer')
            .description('Look up customer information')
            .parameter('phone', 'string', 'Customer phone number', required=True)
            .webhook('GET', 'https://crm.company.com/api/customers/phone/${args.phone}')
            .output(SwaigFunctionResult('Customer: ${response.name} - Account: ${response.account_id}'))
            .error_keys(['error', 'not_found'])
        )

        # Register as a callable function during conversations
        self.register_swaig_function(customer_lookup.to_swaig_function())

Real-Time Session Management πŸ”— ↑ TOC

class SessionAwareAgent(AgentBase):
    def __init__(self):
        super().__init__(name="SessionAgent")
        self.sessions = {}  # In-memory session store

    def on_call_start(self, call_id: str, caller_data: dict):
        # Initialize session state
        self.sessions[call_id] = {
            "start_time": datetime.now(),
            "caller_id": caller_data.get("caller_id_num"),
            "interaction_count": 0
        }

    def on_call_end(self, call_id: str):
        # Clean up session and log analytics
        session = self.sessions.pop(call_id, {})
        duration = datetime.now() - session.get("start_time", datetime.now())
        self.log.info("call_completed", 
                     call_id=call_id, 
                     duration=duration.seconds,
                     interactions=session.get("interaction_count", 0))

    @tool(name="track_interaction")
    def track_interaction(self, args, raw_data):
        call_id = raw_data.get("call_id")
        if call_id in self.sessions:
            self.sessions[call_id]["interaction_count"] += 1
        return SwaigFunctionResult("Interaction tracked")

Key SDK Advantages πŸ”— ↑ TOC

1. Zero Infrastructure Management πŸ”— ↑ TOC

# This is ALL you need for a production-ready AI agent
agent = MyAgent()
agent.run()  # Auto-detects environment (server/CGI/Lambda)

2. Composable by Design πŸ”— ↑ TOC

# Mix and match capabilities like building blocks
agent.add_skill("web_search")
agent.add_skill("database_lookup") 
agent.add_skill("payment_processing")
# Agent now has web search, database access, and payment capabilities

3. Stateless but Context-Aware πŸ”— ↑ TOC

4. SWML Generation on Demand πŸ”— ↑ TOC

# Generate complex SWML dynamically based on business logic
def generate_menu_swml(self, customer_tier):
    if customer_tier == "premium":
        return {
            "play": {"url": "https://assets.com/premium_greeting.mp3"},
            "gather": {
                "input": "dtmf speech",
                "choices": ["sales", "support", "account_manager"]
            }
        }
    else:
        return {
            "play": {"text": "Thank you for calling"},
            "gather": {
                "input": "dtmf",
                "choices": ["1", "2", "3"]
            }
        }

5. Production-Ready Features πŸ”— ↑ TOC


Security and Authentication πŸ”— ↑ TOC

Multi-Layer Security Model πŸ”— ↑ TOC

SignalWire AI implements security at multiple layers:

Transport Security πŸ”— ↑ TOC

Authentication & Authorization πŸ”— ↑ TOC

SWAIG Function Security πŸ”— ↑ TOC

Function calls use a sophisticated token-based security system:

# Token generation (handled automatically by SDK)
tool_token = session_manager.create_tool_token(
    tool_name="get_customer_data",
    call_id="abc-123",
    permissions=["read:customer", "read:account"],
    expires_in=3600  # 1 hour
)

# Token validation during function calls
def validate_function_call(request):
    token = request.headers.get("Authorization")
    function_name = request.json.get("function")
    call_id = request.json.get("call_id")

    if not session_manager.validate_tool_token(
        function_name, token, call_id
    ):
        raise UnauthorizedError("Invalid or expired token")

Data Protection πŸ”— ↑ TOC

Compliance Framework πŸ”— ↑ TOC

SignalWire AI is designed to support enterprise compliance requirements and has demonstrated compliance capabilities across multiple standards:

Certified Compliance Standards πŸ”— ↑ TOC

Security Capabilities πŸ”— ↑ TOC

Compliance-Ready Architecture πŸ”— ↑ TOC

SignalWire's architecture provides the foundation for meeting various industry compliance requirements, with proven implementations for healthcare (HIPAA), payment processing (PCI), and telecommunications (data sovereignty) use cases.


Performance and Scale πŸ”— ↑ TOC

Real-Time Performance Metrics πŸ”— ↑ TOC

SignalWire AI is engineered for real-time performance:

Latency Characteristics πŸ”— ↑ TOC

Component                    | Typical Latency | Max Latency
----------------------------|-----------------|-------------
Speech Recognition          | 50-100ms        | 200ms
AI Model Response           | 200-500ms       | 1000ms
Text-to-Speech Synthesis    | 100-200ms       | 400ms
SWAIG Function Call         | 100-300ms       | 1000ms
End-to-End Turn Latency     | 500-1000ms      | 2000ms

Throughput Capabilities πŸ”— ↑ TOC

Scalability Architecture πŸ”— ↑ TOC

Horizontal Scaling πŸ”— ↑ TOC

Resource Optimization πŸ”— ↑ TOC

Monitoring and Observability πŸ”— ↑ TOC

Built-in Structured Logging πŸ”— ↑ TOC

SignalWire AI provides built-in structured logging capabilities using structlog:

# Built-in structured logging (actually available)
from signalwire_agents import AgentBase

class CustomerServiceAgent(AgentBase):
    def __init__(self):
        super().__init__(name="CustomerService")

    @tool(name="process_payment")
    def process_payment(self, args, raw_data):
        # Use built-in structured logging
        self.log.info("Processing payment", customer_id=args.get("customer_id"))

        try:
            result = self._process_payment_internal(args)
            self.log.info("Payment successful", transaction_id=result.get("id"))
            return SwaigFunctionResult(f"Payment processed: {result.get('id')}")
        except Exception as e:
            self.log.error("Payment failed", error=str(e))
            return SwaigFunctionResult("Payment processing failed")

    def _process_payment_internal(self, args):
        # Integration with external systems
        pass

Logging Features πŸ”— ↑ TOC


Real-World Applications πŸ”— ↑ TOC

Use Cases πŸ”— ↑ TOC

SignalWire AI enables a wide range of applications across industries. The platform is trusted by customers of all sizes, from startups to large enterprises, powering everything from consumer device messaging and contact center solutions to enterprise AI voice systems and next-generation telecommunications infrastructure.

Customer Service πŸ”— ↑ TOC

Sales and Marketing πŸ”— ↑ TOC

Healthcare πŸ”— ↑ TOC

Financial Services πŸ”— ↑ TOC

Integration Examples πŸ”— ↑ TOC

CRM Integration πŸ”— ↑ TOC

class CRMIntegratedAgent(AgentBase):
    def __init__(self, crm_config):
        super().__init__(name="CRMAgent")
        self.crm = CRMClient(crm_config)

    @tool(name="lookup_customer")
    def lookup_customer(self, args, raw_data):
        phone = raw_data.get("caller_id_num")
        customer = self.crm.find_by_phone(phone)
        if customer:
            return SwaigFunctionResult(
                f"Hello {customer.name}, I see you're calling about account {customer.account_id}"
            )
        else:
            return SwaigFunctionResult("I don't find an account with this number")

    @tool(name="create_ticket")
    def create_ticket(self, args, raw_data):
        ticket = self.crm.create_ticket(
            customer_id=args.get("customer_id"),
            issue=args.get("issue_description"),
            priority=args.get("priority", "medium")
        )
        return SwaigFunctionResult(f"Created ticket #{ticket.id}")

Database Integration πŸ”— ↑ TOC

from signalwire_agents.core.data_map import DataMap
from signalwire_agents.core.function_result import SwaigFunctionResult

class DatabaseAgent(AgentBase):
    def __init__(self):
        super().__init__(name="DatabaseAgent")

        # Create DataMap tool for database operations
        user_lookup = (DataMap('get_user_info')
            .description('Get user information from database')
            .parameter('user_id', 'string', 'User ID to look up', required=True)
            .webhook('GET', 'https://your-api.com/users/${args.user_id}')
            .output(SwaigFunctionResult('User: ${response.name} (${response.email}) - Status: ${response.status}'))
            .error_keys(['error'])
        )

        # Register the DataMap tool as a SWAIG function
        self.register_swaig_function(user_lookup.to_swaig_function())

Payment Processing πŸ”— ↑ TOC

class PaymentAgent(AgentBase):
    def __init__(self, stripe_key):
        super().__init__(name="PaymentAgent")
        self.stripe = stripe.StripeClient(stripe_key)

    @tool(name="process_payment")
    def process_payment(self, args, raw_data):
        try:
            charge = self.stripe.charges.create(
                amount=int(args.get("amount") * 100),  # Stripe uses cents
                currency="usd",
                source=args.get("payment_token"),
                description=args.get("description")
            )
            return SwaigFunctionResult(
                f"Payment processed successfully. Transaction ID: {charge.id}"
            )
        except stripe.error.CardError as e:
            return SwaigFunctionResult(
                f"Payment failed: {e.user_message}"
            )

Enterprise Integration Patterns πŸ”— ↑ TOC

API Gateway Integration πŸ”— ↑ TOC

# Use SignalWire AI behind an enterprise API gateway
class EnterpriseAgent(AgentBase):
    def __init__(self):
        super().__init__(name="Enterprise")
        self.configure_auth(
            method="oauth2",
            client_id="enterprise_client",
            client_secret="secure_secret"
        )

    def get_auth_headers(self):
        token = self.oauth_client.get_access_token()
        return {"Authorization": f"Bearer {token}"}

Microservices Architecture πŸ”— ↑ TOC

# Agent as part of a microservices ecosystem
class OrderServiceAgent(AgentBase):
    def __init__(self, service_discovery):
        super().__init__(name="OrderService")
        self.services = service_discovery

    @tool(name="create_order")
    def create_order(self, args, raw_data):
        # Call order service
        order_service = self.services.get_service("order-service")
        order = order_service.create_order(args)

        # Call inventory service
        inventory_service = self.services.get_service("inventory-service")
        inventory_service.reserve_items(order.items)

        # Call payment service
        payment_service = self.services.get_service("payment-service")
        payment = payment_service.process_payment(order.total)

        return SwaigFunctionResult(f"Order {order.id} created successfully")

Getting Started πŸ”— ↑ TOC

Quick Start πŸ”— ↑ TOC

  1. Install the SDK: bash pip install signalwire-agents

  2. Create Your First Agent: ```python from signalwire_agents import AgentBase

class HelloWorldAgent(AgentBase): def get_prompt(self): return "You are a friendly AI assistant"

agent = HelloWorldAgent() agent.run() ```

  1. Deploy and Test:
  2. The agent automatically generates webhook URLs
  3. Configure your SignalWire phone number to point to the webhook
  4. Make a test call to see your agent in action

Advanced Configuration πŸ”— ↑ TOC

For production deployments:

class ProductionAgent(AgentBase):
    def __init__(self):
        super().__init__(
            name="production-agent",
            port=8080,
            basic_auth=("user", "secure_password")
        )

        # Configure logging
        self.setup_logging(level="INFO")

        # Add custom middleware
        self.add_middleware(CORSMiddleware)
        self.add_middleware(SecurityMiddleware)

    def get_prompt(self):
        return self.load_prompt_from_file("prompts/customer_service.txt")

    def on_call_start(self, call_id: str):
        # Custom call initialization
        self.log.info(f"Call started: {call_id}")

    def on_call_end(self, call_id: str):
        # Cleanup and analytics
        self.analytics.track_call_completion(call_id)

Best Practices πŸ”— ↑ TOC

  1. Prompt Engineering: Write clear, specific prompts with examples
  2. Error Handling: Implement robust error handling in SWAIG functions
  3. Testing: Use the built-in testing framework for comprehensive coverage
  4. Monitoring: Implement logging and monitoring for production deployments
  5. Security: Always use authentication and validate inputs

Conclusion πŸ”— ↑ TOC

SignalWire AI represents the convergence of enterprise-grade telecommunications infrastructure and cutting-edge AI technology. By providing native protocol support, real-time processing capabilities, and a developer-friendly SDK, it enables the creation of sophisticated conversational AI applications that can scale to millions of users.

The combination of SWML's declarative approach, SWAIG's powerful function integration, and the platform's global telecommunications infrastructure makes SignalWire AI the definitive platform for building production-ready AI agents.

Whether you're building customer service bots, sales automation tools, or complex multi-modal AI applications, SignalWire AI provides the foundation for reliable, scalable, and secure conversational AI solutions.