AI Voice Assistant

AI Voice Assistant API

This API provides endpoints for managing AI-powered voice communication using Twilio and OpenAI.

POST /api/call

Initiate a phone call with the AI assistant, with customizable voice and message.

API Overview: The /api/call endpoint allows you to initiate a phone call where an AI assistant will speak to the recipient using the selected voice. You can customize the AI's behavior with a system message, select from a variety of voice options, and receive transcription notifications via webhook.

Voice Options

The following voice options are available when making calls:

alloy
Neutral balanced voice (default)
ash
Calm and focused
ballad
Melodic and pleasant
coral
Warm and inviting
echo
Crisp and clear
verse
Expressive and dynamic
sage
Thoughtful and measured
shimmer
Light and optimistic
cedar
Warm and grounded
marin
Fresh and clear

Make a Test Call

Use the form below to initiate a call with custom parameters:

alloy
Leave empty for default 900s timeout. For testing, you can use shorter (e.g., 60) or longer values.

API Usage Examples

cURL Example:

curl -X POST "${window.location.origin}/api/call" \
  -H "Content-Type: application/json" \
  -d '{
    "phone_number": "+12025550195",
    "custom_message": "You are a friendly AI assistant who loves to talk about gardening",
    "voice": "nova",
    "transcription_webhook": "https://webhook.site/your-webhook-id"
  }'

Python Example:

import requests

response = requests.post(
    "${window.location.origin}/api/call",
    json={
        "phone_number": "+12025550195",
        "custom_message": "You are a friendly AI assistant who loves to talk about gardening",
        "voice": "nova",
        "transcription_webhook": "https://webhook.site/your-webhook-id"
    }
)

print(response.json())

JavaScript Example:

fetch(`${window.location.origin}/api/call`, {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json'
    },
    body: JSON.stringify({
        phone_number: '+12025550195',
        custom_message: 'You are a friendly AI assistant who loves to talk about gardening',
        voice: 'nova',
        transcription_webhook: 'https://webhook.site/your-webhook-id'
    })
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));

Response Format

API Response:

{
  "status": "success",
  "call_sid": "CA93b80a9eccd52a20ebc04aee03b8ea1f",
  "message": "Call initiated successfully"
}

Webhook Notification

When transcription is complete, a POST request will be sent to your webhook URL with the following payload:

{
  "call_sid": "CA93b80a9eccd52a20ebc04aee03b8ea1f",
  "phone_number": "+12025550195",
  "transcription": "Hello, this is the AI assistant. How can I help you today? I'm calling about my garden. What plants do you recommend for partial shade?",
  "recording_url": "https://api.twilio.com/2010-04-01/Accounts/ACxxxxxx/Recordings/RExxxxxx.mp3",
  "transcription_time": "2025-05-15T17:18:08.123456"
}

Parameter Details

phone_number (required): The phone number to call in E.164 format (e.g., +12025550195)

custom_message (optional): System prompt for the AI assistant. If not provided, a default prompt will be used.

voice (optional): The OpenAI voice to use. Options: alloy (default), ash, ballad, coral, echo, fable, nova, onyx, sage, shimmer

transcription_webhook (optional): URL that will be called when transcription is complete, with call details in the payload

Interactive API Docs (Swagger UI) View API Info Call History Monitoring