VoiceDock Docs
Features

Campaigns Setup

Technical setup guide for deploying the outbound campaigns infrastructure with Edge Functions and database triggers.

Overview

Outbound campaigns allow you to upload a list of leads and have the system automatically call them sequentially with personalized context.

Architecture

Flow:

  1. User creates campaign with CSV of leads
  2. User starts campaign (status → scheduled)
  3. Edge Function processes first lead
  4. Call happens via LiveKit droplet
  5. When call ends, database trigger fires
  6. Trigger calls Edge Function to process next lead
  7. Repeat until all leads processed

Components:

  • Next.js UI: Campaign creation, management, monitoring
  • Supabase Database: Campaigns, leads, triggers
  • Supabase Edge Function: Campaign processing logic
  • LiveKit Droplet: Call execution

Setup Instructions

1. Deploy Edge Function

cd supabase
supabase functions deploy process-campaign

2. Configure Environment Variables

In Supabase Dashboard → Settings → Edge Functions:

  • DROPLET_INTERNAL_URL: Your LiveKit droplet URL (e.g., http://142.93.xxx.xxx:8082)
  • DROPLET_INTERNAL_KEY: Your droplet internal authentication key

3. Configure Database

Run these SQL commands in Supabase SQL Editor:

-- Set Edge Function URL (replace YOUR_PROJECT_REF)
ALTER DATABASE postgres SET app.supabase_functions_url = 'https://YOUR_PROJECT_REF.supabase.co/functions/v1';

-- Set service role key (from Dashboard → Settings → API)
ALTER DATABASE postgres SET app.supabase_service_role_key = 'eyJh...';

-- Verify
SELECT name, setting FROM pg_settings WHERE name LIKE 'app.%';

4. Optional: Cron Backup

For extra reliability, add a cron job:

Dashboard → Integrations → Cron:

  • Name: process-campaigns-backup
  • Schedule: */2 * * * *
  • Type: HTTP Request
  • Method: POST
  • URL: https://YOUR_PROJECT_REF.supabase.co/functions/v1/process-campaign
  • Headers:
    {
      "Authorization": "Bearer YOUR_SERVICE_ROLE_KEY",
      "Content-Type": "application/json"
    }
  • Body: Check all active campaigns (requires Edge Function modification)

Campaign Lifecycle

Status Flow:

  • draft → Campaign being created
  • scheduled → Active, will process leads during time window
  • paused → Manually paused by user
  • completed → All leads processed

Lead Status Flow:

  • pending → Waiting to be called
  • calling → Call in progress
  • completed → Call finished successfully
  • failed → Call failed or errored

Monitoring

View Edge Function Logs:

supabase functions logs process-campaign --tail

Check Campaign Stats: Query the campaigns table for completed_leads, failed_leads, and total_leads.

Debug Stuck Campaigns: Check last_lead_processed_at - if older than 5 minutes and status is scheduled, campaign may be stuck.

Troubleshooting

Campaigns not processing:

  1. Check Edge Function deployment: supabase functions list
  2. Verify database settings: SELECT name, setting FROM pg_settings WHERE name LIKE 'app.%';
  3. Check Edge Function logs for errors
  4. Verify droplet is accessible from Supabase

Calls not initiating:

  1. Check droplet logs
  2. Verify organization has active phone number and SIP trunk
  3. Verify organization has sufficient balance
  4. Check Edge Function logs for detailed error

Time window not working:

  1. Verify campaign timezone is correct
  2. Check schedule_start_time and schedule_end_time format (HH:MM:SS)
  3. Edge Function logs will show "Outside time window" message

On this page