This API provides endpoints for managing AI-powered voice communication using Twilio and OpenAI.
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.
The following voice options are available when making calls:
Use the form below to initiate a call with custom parameters:
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"
}'
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())
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));
{
"status": "success",
"call_sid": "CA93b80a9eccd52a20ebc04aee03b8ea1f",
"message": "Call initiated successfully"
}
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"
}
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