How to connect real phone service so AI actually answers calls with custom prompts
Why Vapi: Easiest setup, handles all telephony, built-in OpenAI integration, ~$0.05-0.10/min
Go to Base44 Dashboard → Settings → Enable Backend Functions
This lets you create server-side code that Vapi can call
Create this backend function in Base44:
// functions/getAIInstructions.js
export default async function getAIInstructions({ phone_number }) {
const configs = await base44.entities.AIConfiguration.filter({
assigned_phone: phone_number
});
if (configs.length === 0) {
return {
instructions: "Hello, thank you for calling.",
company_name: "Our Company"
};
}
const config = configs[0];
return {
instructions: config.ai_instructions,
company_name: config.company_name,
voice_accent: config.voice_accent,
voice_tone: config.voice_tone
};
}Sign up at vapi.ai and get your API key
Store it in Base44: Settings → Secrets → Add "VAPI_API_KEY"
In Vapi dashboard, create assistant and configure:
Add this to your Onboarding completion:
const response = await fetch('https://api.vapi.ai/phone-number', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_VAPI_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
provider: "twilio",
assistantId: "your-assistant-id"
})
});
const { phoneNumber } = await response.json();
// Save to user's config
await base44.entities.AIConfiguration.update(configId, {
assigned_phone: phoneNumber,
status: 'active'
});Simpler API, less customization than Vapi
const response = await fetch('https://api.bland.ai/v1/agents', {
method: 'POST',
headers: {
'authorization': 'YOUR_BLAND_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
prompt: userConfig.ai_instructions,
voice: userConfig.voice_accent,
phone_number: "buy_new"
})
});Get API key from bland.ai
Warning: Much more complex. Requires webhook setup, WebSocket handling, and OpenAI Realtime API integration.
You'll need:
See Twilio's WebSocket documentation for full implementation