AgenticUniverse - Previously Formi
  1. Connection Configuration
AgenticUniverse - Previously Formi
  • Our Technical Note
    • Why Open AI is not Enough
    • How business Outcomes would Change Radically with AgenticUniverse
    • Our Research
      • STT - Nuances and Insights
      • Solving for STT Constraints
  • Generate Token
    • Login/Generate Token
      POST
  • Agent Configuration
    • Model Configuration
      • Configuration Helpers
        • Supported Providers
        • Supported Models
        • Supported Parameters
      • Get Model Configuration
      • Set Model Configuration
    • State Machine
      • Edge
        • Legacy
          • Create Edge
          • Edge Details
          • Update Edge
          • Delete Edge
        • Update edge properties
        • Get edge details
        • Delete an edge
        • Create an edge (transition) between two states
      • State
        • Create State from Template
        • Get State Information
        • Update State
        • Delete State
      • Get State Machine Structure
    • Prompt Templates
      • Get All Templates
      • Render Template
    • Tools
      • Get Tools List
      • Add Tool
      • Update Tool
      • Delete Tool
    • Get All Agents
      GET
    • Single Agent Details
      GET
    • Create Agent
      POST
    • Update Agent Details
      PUT
    • Enable Dashboard For An Outlet
      POST
    • Disable Dashboard For An Outlet
      POST
    • Get Call queue Sheet ID
      GET
  • Interactions
    • Pre-Interaction Context
      • Schedule an Interaction
      • Update an Interaction Id
      • Delete an Interaction Id
      • Clear all interactions
      • Get Summarized Interaction Info
    • Interaction Modalities
      • Video
        • Generation
          • Generate Welcome Video
      • Text
        • Start Interaction
        • Create Response
        • End Interaction
      • Voice
        • Connection Configuration
          • Quickstart
          • Connecting Twilio
          • Connecting Exotel
          • Formi WebSocket Configuration Guide
          • Create a New Connection Vendor
            POST
          • Get All Connection Vendors
            GET
          • Update a Connection Vendor
            PUT
          • Delete a Connection Vendor
            DELETE
          • Get Agent's Connection Config
            GET
          • Add or Update Agent's Connection Config
            POST
    • Post Interaction Configuration
      • Email Destination Configuration
      • Variables CRUD
        • Get all required variables for the outlet with map
        • Modify variable definition for outlet
        • Add a new variable for the outlet
        • DELETE variable for outlet
        • Connect Variable to a destination
      • Destinations CRUD
        • Get all destinations for the outlet
        • Modify Destination for outlet
        • Add a new Destination for the outlet
        • DELETE Destinations for outlet
    • Get Interaction Summary
      GET
    • Resolve an Escalated Interaction
      POST
    • Get the Interaction list
      GET
    • Get Information regarding Single Interaction
      GET
  • Agent Utilisation
    • Get Credits Available
    • Interaction Utilisation
    • Model Utilisation
  • Webhooks
    • Get webhook URL
    • Update webhook URL
    • Get webhook metadata
    • Modify webhook metadata
    • Get reservation ingestion metadata
  • Untitled Endpoint
    POST
  1. Connection Configuration

Formi WebSocket Configuration Guide

Overview#

Formi enables intelligent AI-powered voice interactions over phone calls through real-time audio streaming. This guide is for any client or partner integrating third-party telephony services (e.g., Exotel, Twilio, Knowlarity, Convox, Tata Tele etc.) with Formi using WebSockets.
This documentation provides a comprehensive guideline on how to:
Set up the WebSocket connection
Validate the set of events that Formi's system expects
Configure audio formatting that Formi's system expects
Establish a direct WebSocket connection with Formi
Stream and receive audio in real-time
It is designed for teams implementing either:
Unidirectional streams (call monitoring or transcription)
Bidirectional streams (interactive AI voice agents)

WebSocket Connection URL#

Connection Endpoint#

wss://<formi’s-domain>/ws-adapter/{provider}/{call_type}/{agent_id}/{outlet_id}/{virtual_number}?caller_id={caller_id}
<formi’s-domain> : staging-api-2.formi.co.in or api-2.formi.co.in

Required Path Parameters#

ParameterTypeDescriptionExample
providerstringShort name for telephony provider (lowercase)twilio, exotel
call_typestringDirection of the call, one of inbound or outboundinbound, outbound
agent_idintegerUnique identifier for the agent12345
outlet_idintegerUnique identifier for the outlet/client67890
virtual_numberstringUnique identifier for the configured number+1234567890

Optional Query Parameters#

ParameterTypeDescriptionDefault
caller_idstringCustomer's phone numberAuto-generated UUID

Example Connection URLs#

# Twilio inbound call
wss://staging-api-2.formi.co.in/ws-adapter/twilio/inbound/123/456/1234567890?caller_id=919701966915
# Exotel outbound call
wss://api-2.formi.co.in/ws-adapter/exotel/outbound/789/012/09876543211?caller_id=9701966915

Universal Telephony Adapter#

Formi's Universal Telephony Adapter is designed to work with any telephony provider regardless of their specific event naming conventions, payload structures, or audio encoding formats. The system adapts to different provider implementations while maintaining consistent internal processing**

Key Features#

Provider Agnostic: Works with any telephony provider's WebSocket implementation
Dynamic Event Mapping: Automatically maps provider-specific events to Formi's internal event types
Audio Format Flexibility: Supports multiple audio encoding formats and automatic conversion
Template-Based Configuration: Uses JSON templates for easy provider integration

Event Types and Requirements#

Formi expects four mandatory event types from all telephony providers. These events can have different names and payload structures across providers, but the core functionality must be present.

1. Handshake Event (Connected and Stop Event)#

Purpose: Establishes the WebSocket connection and confirms the communication channel is ready at the start of the call and sends acknowledgement in a similar manner at the end of the call.
Formi Internal Name: connected, stop
Requirements:
Must be the first event sent after WebSocket connection
Should contain connection metadata
Confirms bidirectional communication capability
Expected Information:
Connection status
Session identifier (if available)
Provider-specific metadata

2. Meta Event (Start Event)#

Purpose: Initiates the call session and provides call context.
Formi Internal Name: start
Requirements:
Must be sent before audio streaming begins
Contains call setup information
Provides context for the AI system
Expected Information:
Call direction (inbound/outbound)
Caller information
Call timestamp
Any additional call metadata

3. Audio Event (Media Event)#

Purpose: Streams real-time audio data between telephony provider and Formi.
Formi Internal Name: media
Requirements:
MANDATORY: Must support bidirectional audio streaming
Must maintain consistent audio format throughout the session
Should handle audio buffering appropriately
Must support real-time streaming with minimal latency
Audio Format Requirements:
Sample rate: 8kHz (preferred) or 16kHz
Encoding: PCM, μ-law, or A-law
Channels: Mono (1 channel)
Bit depth: 8-bit or 16-bit

4. Control Event (Mark and Clear Events)#

Purpose: Handles call control operations and state management.
Formi Internal Name: mark, clear
Requirements:
Clear Event: MANDATORY - Used for user’s interruptions handling during the call with our AI agent
Mark Event: OPTIONAL - Used for marking specific points in audio stream
Must support session termination events
Control Operations:
Audio buffer management, clear event should clear all the audio that is yet to be played from the audio buffer.
Session state changes

Audio Event Specifications#

Supported Audio Formats#

Input Audio Formats (From Provider to Formi)#

1.
Binary PCM: Raw binary audio data
2.
Base64 PCM: PCM audio encoded in Base64
3.
μ-law Base64: μ-law encoded audio in Base64 format

Output Audio Formats (From Formi to Provider)#

1.
Base64 PCM: PCM audio encoded in Base64
2.
μ-law Base64: μ-law encoded audio in Base64 format

Audio Configuration Parameters#

{
"sample_rate": 8000,
"encoding": "PCM_16_LE",
"channels": 1,
"bit_depth": 16,
"chunk_size_ms": 20
}

Audio Processing Rules#

1.
Sample Rate Conversion: Automatic conversion between different sample rates
2.
Channel Conversion: Support for mono/stereo conversion
3.
Format Conversion: Automatic encoding/decoding between supported formats
4.
Buffer Management: Proper handling of audio chunks and streaming

Provider Implementation Requirements#

Mandatory Event Validation Checklist#

Before integrating with Formi, telephony providers must validate that their system supports all four event types:
Handshake Event: Connection establishment and disconnected events are implemented
Meta Event: Call initiation event with metadata is implemented
Audio Event: Bidirectional audio streaming is implemented
Control Event: At least clear event is implemented
Mark Event: Optional - Stream marking capability

Event Mapping Configuration#

Each provider needs to provide a configuration mapping their events to Formi's expected format:
{
"provider": "your_provider_name",
"events": {
"incoming": {
"message_patterns": {
"connected": {
"detection_pattern": {"event": "connection_established"},
"extraction_map": {"status": "connection.status"}
},
"start": {
"detection_pattern": {"event": "call_started"},
"extraction_map": {"call_id": "call.id", "direction": "call.direction"}
},
"media": {
"detection_pattern": {"event": "audio_data"},
"extraction_map": {"audio": "payload.audio_data"}
},
"clear": {
"detection_pattern": {"event": "buffer_clear"},
"extraction_map": {"action": "control.action"}
}
}
}
}
}

Audio Stream Requirements#

1.
Continuous Streaming: Audio must be streamed continuously without gaps
2.
Real-time Processing: Latency should be minimized (< 100ms recommended)
3.
Buffer Management: Proper audio buffering to prevent dropouts
4.
Error Handling: Graceful handling of audio processing errors
5.
Format Consistency: Maintain consistent audio format throughout session

Error Handling#

Providers should implement proper error handling for:
Connection failures
Audio format mismatches
Network interruptions
Buffer overflow/underflow
Invalid event formats

Integration Testing#

Test Scenarios#

1.
Connection Test: Verify WebSocket connection establishment
2.
Event Sequence Test: Validate all four mandatory events are sent in correct order
3.
Audio Streaming Test: Confirm bidirectional audio streaming works
4.
Error Recovery Test: Test handling of connection drops and recovery
5.
Format Compatibility Test: Verify audio format conversion works correctly

Sample Test Implementation#

// Example test for event validation
const testEvents = [
'handshake/connected', // Must be present
'meta/start', // Must be present
'audio/media', // Must be present
'control/clear' // Must be present
// 'control/mark' // Optional
];
function validateProviderEvents(providerEvents) {
const requiredEvents = testEvents.slice(0, 4); // First 4 are mandatory
return requiredEvents.every(event =>
providerEvents.some(pe => pe.mapsTo === event)
);
}

Best Practices#

For Telephony Providers#

1.
Event Ordering: Send events in the correct sequence (handshake → meta → audio/control → stop)
2.
Audio Quality: Ensure high-quality audio with minimal noise and distortion
3.
Latency Optimization: Minimize processing delays in audio pipeline
4.
Resource Management: Properly manage memory and connection resources
5.
Documentation: Provide clear documentation of your event formats and audio specifications

For Integration Teams#

1.
Configuration Testing: Thoroughly test event mapping configurations
2.
Audio Format Validation: Verify audio format compatibility before production
3.
Load Testing: Test system under realistic call volumes
4.
Monitoring Setup: Implement proper logging and monitoring for debugging
5.
Fallback Mechanisms: Implement fallback procedures for connection failures

Support and Documentation#

For technical support and additional documentation:
Formi's API Documentation for configuring telephony
Twilio websocket documentation reference
Exotel websocket documentation reference
Modified at 2025-08-12 14:20:14
Previous
Connecting Exotel
Next
Create a New Connection Vendor
Built with