Step-by-Step Guide: How to Set Up Outbound AI Calling
Ready to supercharge your outbound sales? Learn the step-by-step technical architecture to deploy automated outbound AI calls that qualify leads and book meetings 24/7.
For sales and support teams, outbound cold calling and lead qualification are highly resource-intensive. Implementing an automated outbound AI calling agent allows your organization to instantly contact leads the moment they submit a form, dramatically raising lead conversion rates (the "speed-to-lead" effect).
This guide provides a comprehensive technical walkthrough for developers and operations managers on how to build, deploy, and scale an automated outbound AI calling pipeline using Retell AI, Supabase Edge Functions, and modern webhook architectures.
1. The System Architecture Overview
A robust outbound AI calling funnel operates through four distinct layers to ensure speed, safety, and reliability:
- Lead Capture: The user fills out a lead capture form on your landing page.
- Edge Function Security Gate: A secure backend function (e.g., Supabase Edge Functions) validates the form payload, filters out spam bots, and triggers the voice agent.
- Outbound API Call: The edge function communicates securely with the Retell AI
/v2/create-phone-callAPI to initiate the call. - Post-Call CRM Sync: A webhook executes at the end of the call, parsing the transcript and syncing lead qualification details back to your CRM (e.g., HubSpot).
2. Step-by-Step Technical Setup
Step 1: Telephony Configuration & Twilio Setup
To run outbound campaigns, you must buy and configure a dedicated phone number. If using Twilio, follow these steps:
- Purchase a clean local or toll-free E.164 format number.
- Submit your A2P 10DLC registration profile to comply with US carrier guidelines and prevent your calls from being blocked as spam.
- Connect your Twilio number to your Retell AI dashboard by configuring your Twilio Account SID and Auth Token under the Telephony settings.
Step 2: Designing the AI Agent's Prompt
Your agent's prompt determines how effectively it handles objections and guides the conversation. A high-performing system prompt structure should include:
[Identity & Role]
You are a friendly, highly professional sales representative at The AI Call. Your goal is to qualify the lead and book a free demo.
[Conversational Style]
- Keep responses short, direct, and conversational (under 30 words).
- Speak with natural emotional cadence; do not sound robotic.
- Never interrupt the user unless they explicitly ask a question.
[Funnel Steps]
1. Greet the lead and mention the form they just submitted.
2. Ask about their current missed call volume.
3. If they qualify, invite them to book a free demo.
Step 3: Deploying the Outbound Supabase Edge Function
Below is a production-ready, fully commented TypeScript code block for your edge function to securely trigger outbound calls:
import { serve } from "https://deno.land/std@0.168.0/http/server.ts"
const RETELL_API_KEY = Deno.env.get("RETELL_API_KEY")
const RETELL_AGENT_ID = Deno.env.get("RETELL_AGENT_ID")
const TWILIO_FROM_NUMBER = Deno.env.get("TWILIO_FROM_NUMBER")
serve(async (req) => {
// Handle CORS
if (req.method === 'OPTIONS') {
return new Response('ok', { headers: { 'Access-Control-Allow-Origin': '*' } })
}
try {
const { phone, name } = await req.json()
// 1. Basic validation
if (!phone) {
return new Response(JSON.stringify({ error: "Phone number is required." }), {
status: 400,
headers: { "Content-Type": "application/json" }
})
}
// 2. Trigger Retell AI Outbound Call
const res = await fetch("https://api.retellai.com/v2/create-phone-call", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${RETELL_API_KEY}`
},
body: JSON.stringify({
from_number: TWILIO_FROM_NUMBER,
to_number: phone,
override_agent_id: RETELL_AGENT_ID,
retell_llm_dynamic_variables: {
customer_name: name || "there"
}
})
})
if (!res.ok) {
throw new Error(`Retell API error: ${await res.text()}`)
}
const data = await res.json()
return new Response(JSON.stringify({ success: true, call_id: data.call_id }), {
status: 200,
headers: { "Content-Type": "application/json" }
})
} catch (error) {
return new Response(JSON.stringify({ error: error.message }), {
status: 500,
headers: { "Content-Type": "application/json" }
})
}
})
3. Telephony Compliance & TCPA Guardrails
Outbound campaigns must comply with legal standards. Keep this compliance checklist handy:
- Prior Consent: Never make automated calls to phone numbers without explicit, documented written consent.
- Permissible Hours: Restrict calling to local hours between 8:00 AM and 9:00 PM.
- Automated Opt-Out: Program your agent to recognize opt-out phrases (like "remove me" or "don't call again") and immediately end the call, adding the number to your DNC list.
- Clear Identification: Ensure the agent introduces your business and discloses that the call is AI-assisted in its opening sentence.
Implementing these steps creates a highly efficient, compliant outbound calling machine that connects with leads in real-time, driving massive conversion improvements for your sales team.