Back to page

ARI Integration Layer

Raw Markdown & AI/RAG Chunks
Raw Markdown Source 2615 chars
# ARI Integration Layer

The Asterisk REST Interface (ARI) integration architecture enables asynchronous control over raw voice channels. By transferring media operations into a specialized background event bus, **Asterisk 2** lets high-level AppFlow visual structures control active call legs directly.

---

## Asynchronous Stasis Handshake Architecture

The diagram below details the decoupled event loop connecting raw telecommunication channels directly to C# execution blocks:

```mermaid
graph LR
    %% Telephony Core
    subgraph StasisApp["Asterisk PBX Core"]
        CallLeg["Active Voice Channel Leg"]
        StasisLoop["Internal Stasis App Loop"]
    end

    %% Transport Layer
    subgraph EventBus["Network WebSocket Bridge"]
        WS_Conn["Persistent WebSocket Connection"]
    end

    %% Application Core
    subgraph AppOrchestration["ASP.NET Core Application Context"]
        ARI_Client["Asynchronous ARI Listener"]
        FlowEngine["AppFlow Engine Integration"]
        CmdDispatcher["REST Action Commander"]
    end

    %% Routing Logic
    CallLeg -->|"Trigger Call Setup"| StasisLoop
    StasisLoop ==>|"Stream JSON Event Payload"| WS_Conn
    WS_Conn ==>|"Deserialize to C# Object"| ARI_Client
    ARI_Client ==>|"Publish Internal Notification"| FlowEngine
    FlowEngine -->|"Evaluate Visual Node Matrix"| CmdDispatcher
    CmdDispatcher ==>|"POST REST Directive<br/>(Play Audio, Hangup, Bridge)"| StasisLoop

    %% Aesthetic Style Matrix
    classDef stasisFill fill:#1e293b,stroke:#a855f7,stroke-width:2px,color:#fff,rx:6px,ry:6px;
    classDef wsFill fill:#0f172a,stroke:#38bdf8,stroke-width:2px,color:#fff,rx:6px,ry:6px;
    classDef appFill fill:#065f46,stroke:#10b981,stroke-width:2px,color:#fff,rx:6px,ry:6px;

    class StasisApp,CallLeg,StasisLoop stasisFill;
    class EventBus,WS_Conn wsFill;
    class AppOrchestration,ARI_Client,FlowEngine,CmdDispatcher appFill;
```

---

## Core Media Manipulation Functions

### 1. Ingress Interception & Leg Tracking
When an incoming call enters an ARI extension, Asterisk moves channel control directly into the `Stasis` application. The ASP.NET Core listener maps the session identifier to a state container, ensuring complete observability over DTMF button presses, channel state changes, and audio recording operations.

### 2. Multi-Leg Channel Bridging
To connect independent caller sessions securely, the engine executes direct RPC actions over the REST pipeline to provision native audio bridges. This isolates customer channels while ensuring unified recording pipelines can track concurrent conversational audio streams.
AI Chunks (RAG) 3 chunks
Chunk #1 ARI Integration Layer
# ARI Integration Layer

The Asterisk REST Interface (ARI) integration architecture enables asynchronous control over raw voice channels. By transferring media operations into a specialized background event bus, **Asterisk 2** lets high-level AppFlow visual structures control active call legs directly.

---
Chunk #2 Asynchronous Stasis Handshake Architecture
## Asynchronous Stasis Handshake Architecture

The diagram below details the decoupled event loop connecting raw telecommunication channels directly to C# execution blocks:

```mermaid
graph LR
    %% Telephony Core
    subgraph StasisApp["Asterisk PBX Core"]
        CallLeg["Active Voice Channel Leg"]
        StasisLoop["Internal Stasis App Loop"]
    end

    %% Transport Layer
    subgraph EventBus["Network WebSocket Bridge"]
        WS_Conn["Persistent WebSocket Connection"]
    end

    %% Application Core
    subgraph AppOrchestration["ASP.NET Core Application Context"]
        ARI_Client["Asynchronous ARI Listener"]
        FlowEngine["AppFlow Engine Integration"]
        CmdDispatcher["REST Action Commander"]
    end

    %% Routing Logic
    CallLeg -->|"Trigger Call Setup"| StasisLoop
    StasisLoop ==>|"Stream JSON Event Payload"| WS_Conn
    WS_Conn ==>|"Deserialize to C# Object"| ARI_Client
    ARI_Client ==>|"Publish Internal Notification"| FlowEngine
    FlowEngine -->|"Evaluate Visual Node Matrix"| CmdDispatcher
    CmdDispatcher ==>|"POST REST Directive<br/>(Play Audio, Hangup, Bridge)"| StasisLoop

    %% Aesthetic Style Matrix
    classDef stasisFill fill:#1e293b,stroke:#a855f7,stroke-width:2px,color:#fff,rx:6px,ry:6px;
    classDef wsFill fill:#0f172a,stroke:#38bdf8,stroke-width:2px,color:#fff,rx:6px,ry:6px;
    classDef appFill fill:#065f46,stroke:#10b981,stroke-width:2px,color:#fff,rx:6px,ry:6px;

    class StasisApp,CallLeg,StasisLoop stasisFill;
    class EventBus,WS_Conn wsFill;
    class AppOrchestration,ARI_Client,FlowEngine,CmdDispatcher appFill;
```

---
Chunk #3 Core Media Manipulation Functions
## Core Media Manipulation Functions

### 1. Ingress Interception & Leg Tracking
When an incoming call enters an ARI extension, Asterisk moves channel control directly into the `Stasis` application. The ASP.NET Core listener maps the session identifier to a state container, ensuring complete observability over DTMF button presses, channel state changes, and audio recording operations.

### 2. Multi-Leg Channel Bridging
To connect independent caller sessions securely, the engine executes direct RPC actions over the REST pipeline to provision native audio bridges. This isolates customer channels while ensuring unified recording pipelines can track concurrent conversational audio streams.