Overview
Highway uses OpenAI’s Realtime API to power intelligent, natural phone conversations for identity verification. The AI agent conducts real-time voice calls, asks verification questions, and determines whether the customer’s identity can be confirmed.How AI Verification Calls Work
Call Initiated
When you click “Initiate call” in the dashboard, Highway uses Twilio to place a phone call to the customer and establishes a WebSocket connection to stream audio.
AI Connection
The audio stream connects to OpenAI’s Realtime API (
gpt-4o-realtime-preview-2024-10-01) via WebSocket, enabling real-time conversation.Context Loading
The system loads verification data from Supabase and injects it into the AI’s context as a system prompt.
Conversation Flow
The AI agent introduces itself, explains the call purpose, and asks 2 verification questions one at a time based on the verification data.
Verification Decision
After the conversation, the AI determines if the identity was successfully verified and updates the call status.
OpenAI Realtime API Integration
Highway integrates with OpenAI’s Realtime API to enable natural voice conversations. The connection is established via WebSocket athighway-backend/websocket.js:18-26:
WebSocket Connection
Session Configuration
The AI session is configured with specific parameters for optimal phone call performance (highway-backend/conversationConfig.js:3-51):
- Audio Settings
- Detection Settings
- Model Settings
- Audio Format:
g711_ulaw- Standard telephony codec compatible with Twilio - Voice:
shimmer- OpenAI’s natural-sounding female voice
Conversation Flow
The AI agent follows a structured conversation flow designed for effective identity verification:1. Introduction Phase
The AI agent is instructed to introduce itself and explain the purpose of the call (highway-backend/websocket.js:56-60):
System Prompt
The AI uses the background field from the verification to explain why the call is happening.
2. Question Phase
The AI asks questions based on the verification data:- Two questions total - Keeps the call focused and efficient
- One at a time - Allows customer to answer fully before moving on
- Based on verification data - AI selects appropriate questions from the JSON data
- No confirmation - AI doesn’t reveal the correct answers, only asks questions
3. Completion Phase
After gathering responses, the AI:- Thanks the customer for their time
- Determines verification outcome (successful or unsuccessful)
- Ends the call gracefully
Voice Configuration
Highway uses OpenAI’s shimmer voice for all verification calls (highway-backend/config.js:7):
Voice Characteristics
Natural & Professional
Shimmer provides a warm, professional tone appropriate for business calls and identity verification scenarios.
Clear Articulation
Excellent clarity for phone calls, ensuring customers can understand questions even on poor connections.
Conversational Pace
Natural speaking rhythm that doesn’t feel rushed or robotic.
Consistent Quality
Reliable voice quality across all calls for a professional brand experience.
System Prompts and Instructions
The AI agent receives specific instructions to guide its behavior during calls.Base System Message
Fromhighway-backend/config.js:8-9:
Why This Approach?
Why This Approach?
This system message design:
- Defines scope: Agent only follows SYSTEM instructions, preventing off-script behavior
- Sets tone: “Cheerful phone assistant” creates a friendly customer experience
- Establishes authority: Agent understands it works for Olive Financial
- Prevents hallucination: “Do not ask additional questions” keeps conversation focused
- Clear format:
SYSTEM:(MESSAGE)pattern separates instructions from conversation
Dynamic Verification Instructions
When a call starts, verification-specific instructions are injected (highway-backend/websocket.js:56-60):
- Company introduction (Olive Financial)
- Background context (e.g., “customer signed up for a loan”)
- Verification data (JSON object with information to verify)
- Clear instructions (ask 2 questions, one at a time, don’t confirm answers)
Call Functions
The AI agent has access to two specialized functions for call management:hang_up_call Function
Fromhighway-backend/conversationConfig.js:17-27:
- Purpose
- Behavior
- Guidelines
Allows the AI to gracefully end the call when:
- All verification questions have been asked
- Customer explicitly requests to end the call
- Conversation has reached a natural conclusion
call_reflection_data Function
Fromhighway-backend/conversationConfig.js:28-50:
- Purpose
- Status Values
- Execution
- Trigger
Records the outcome of the verification call by updating the call status in the database.
Audio Streaming
Highway implements bidirectional audio streaming between Twilio and OpenAI:Customer Audio → OpenAI
Fromhighway-backend/websocket.js:126-151:
OpenAI → Customer Audio
Fromhighway-backend/websocket.js:105-114:
Audio is streamed in real-time using base64-encoded
g711_ulaw format, ensuring low latency and natural conversation flow.Best Practices
Verification Data Quality
Verification Data Quality
- Provide clear, unambiguous verification data points
- Use simple field names (“date of birth” vs “dob_mm_dd_yyyy”)
- Include 3-5 data points so AI has question variety
- Test with sample data before production calls
Question Design
Question Design
- Questions should have specific, verifiable answers
- Avoid yes/no questions when possible
- Use multiple-choice options for complex questions
- Ensure questions are appropriate for phone conversation
Background Context
Background Context
- Keep background concise but informative
- Explain the business context clearly
- Helps AI introduce the call naturally
- Sets customer expectations for the conversation
Error Handling
Error Handling
- Monitor system_error statuses in call logs
- Check OpenAI API connection health
- Verify Twilio phone number configuration
- Review WebSocket error logs for debugging
Monitoring & Debugging
Event Logging
Highway logs specific OpenAI events for monitoring (highway-backend/config.js:10-18):
- When the AI starts and stops listening
- When responses are generated and completed
- Rate limit status with OpenAI
- Session lifecycle events
Common Issues
Next Steps
Call Monitoring
Learn how to track call status and view results
Verification Management
Create and manage verification records
Configuration
Set up OpenAI and Twilio credentials
API Reference
Technical details of the call API