VICIDIAL Integration
Connect VICIDIAL dialer to your AI agents β pass lead data via SIP headers
Loading agents...
How It Works
VICIDIAL
Dials lead, sends SIP
X-* headers = lead data
β
Asterisk
Extracts headers
Registers call + AudioSocket
β
AI Agent
Receives lead data
Uses it in conversation
Step 1: PJSIP Endpoint
Asterisk ConfigAdd this PJSIP trunk endpoint. The IP allowlist is managed dynamically from Settings β SIP Allowlist.
pjsip.conf
; PJSIP endpoint for VICIDIAL trunk ; Add to pjsip.conf or pjsip_webrtc.conf [vicidial-trunk] type=endpoint context=viciagent-vicidial disallow=all allow=slin,ulaw aors=vicidial-trunk ; IP allowlist is auto-managed via Settings > SIP Allowlist [vicidial-trunk] type=aor max_contacts=1 [vicidial-trunk] type=identify ; IPs are auto-populated from ps_endpoint_id_ips realtime table endpoint=vicidial-trunk
Step 2: Dialplan
Asterisk ConfigThis dialplan extracts SIP headers from VICIDIAL and passes them to the AI agent. All lead data (name, email, phone, address, campaign) is forwarded automatically.
extensions_viciagent.conf
; ============================================================
; ViciAgent AI - VICIDIAL Remote Agent Dialplan
; Add this to extensions.conf or extensions_custom.conf
; ============================================================
[viciagent-vicidial]
; Map DID to your AI agent
exten => 8001,1,NoOp(=== VICIDIAL -> AI Agent ===)
same => n,Set(VICIAGENT_ID=YOUR_AGENT_ID)
same => n,Goto(vicidial-connect,s,1)
; Or dial agent UUID directly
exten => _X.,1,NoOp(=== VICIDIAL -> Agent UUID=${EXTEN} ===)
same => n,Set(VICIAGENT_ID=${EXTEN})
same => n,Goto(vicidial-connect,s,1)
[vicidial-connect]
exten => s,1,NoOp(Agent=${VICIAGENT_ID} Caller=${CALLERID(num)})
same => n,Answer()
same => n,Set(CALL_UUID=${SHELL(uuidgen | tr -d '\n')})
same => n,Set(CUSTOMER_PHONE=${CALLERID(num)})
same => n,Set(CUSTOMER_NAME=${CALLERID(name)})
; --- Extract SIP headers from VICIDIAL ---
same => n,Set(VD_LEAD_ID=${PJSIP_HEADER(read,X-Lead-ID)})
same => n,Set(VD_CALL_ID=${PJSIP_HEADER(read,X-VICIdial-Call-ID)})
same => n,Set(VD_UNIQUE=${PJSIP_HEADER(read,X-VICIdial-UniqueID)})
same => n,Set(VD_REMOTE=${PJSIP_HEADER(read,X-Remote-User)})
same => n,Set(VD_CAMPAIGN=${PJSIP_HEADER(read,X-Campaign-ID)})
same => n,Set(VD_LIST=${PJSIP_HEADER(read,X-List-ID)})
same => n,Set(VD_FNAME=${PJSIP_HEADER(read,X-First-Name)})
same => n,Set(VD_LNAME=${PJSIP_HEADER(read,X-Last-Name)})
same => n,Set(VD_PHONE=${PJSIP_HEADER(read,X-Phone-Number)})
same => n,Set(VD_EMAIL=${PJSIP_HEADER(read,X-LeadMetadata-email)})
same => n,Set(VD_CITY=${PJSIP_HEADER(read,X-City)})
same => n,Set(VD_STATE=${PJSIP_HEADER(read,X-State)})
same => n,Set(VD_ZIP=${PJSIP_HEADER(read,X-Postal-Code)})
same => n,Set(VD_SESSION=${IF($["${VD_CALL_ID}" != ""]?${VD_CALL_ID}:${PJSIP_HEADER(read,X-Vicidial-Session-Id)})})
same => n,Set(VD_AGENT=${IF($["${VD_REMOTE}" != ""]?${VD_REMOTE}:${PJSIP_HEADER(read,X-Vicidial-Agent-User)})})
same => n,Set(VD_URL=${PJSIP_HEADER(read,X-Vicidial-Url)})
; --- Register call with metadata, then connect AudioSocket ---
same => n,Set(CURLOPT(httpheader)=Content-Type: application/json)
same => n,Set(CURL_RESULT=${CURL(http://127.0.0.1:8765/calls/register,{"call_uuid":"${CALL_UUID}","agent_id":"${VICIAGENT_ID}","caller_id":"${CUSTOMER_PHONE}","caller_name":"${CUSTOMER_NAME}","vicidial_session_id":"${VD_SESSION}","vicidial_agent_user":"${VD_AGENT}","vicidial_url":"${VD_URL}","vicidial_lead_id":"${VD_LEAD_ID}","vicidial_call_id":"${VD_CALL_ID}","vicidial_unique_id":"${VD_UNIQUE}","vicidial_campaign":"${VD_CAMPAIGN}","vicidial_list_id":"${VD_LIST}","vicidial_first_name":"${VD_FNAME}","vicidial_last_name":"${VD_LNAME}","vicidial_phone":"${VD_PHONE}","vicidial_email":"${VD_EMAIL}","vicidial_city":"${VD_CITY}","vicidial_state":"${VD_STATE}","vicidial_zip":"${VD_ZIP}"})})
same => n,AudioSocket(${CALL_UUID},127.0.0.1:9092)
same => n,Hangup()Key:
PJSIP_HEADER(read,X-*) extracts the SIP headers. The CURL() call sends all extracted data to the voice agent. No reload needed β Asterisk reads the IP allowlist on each INVITE.Step 3: VICIDIAL Remote Agent
VICIDIAL AdminConfigure a Remote Agent in VICIDIAL so the dialer routes connected calls to your AI agent.
VICIDIAL Admin β Remote Agents:
Extension:
Local/YOUR_AGENT_ID@viciagent-vicidialServer IP:
your-server.comConf Exten:
YOUR_AGENT_IDStatus:
ACTIVEDon't forget: Add your VICIDIAL server's IP to the
SIP Allowlist
in Settings, or the SIP INVITE will be rejected.
Connection Details
AudioSocket
127.0.0.1:9092TCP β bidirectional audio
Call Registration
127.0.0.1:8765HTTP β POST /calls/register
Audio Format
16-bit slin, 8kHz, mono No codec config needed