Walk through every layer without a VoIP SIP trunk or a persistent USB cable: connect a SIM-enabled, rooted Samsung Android (12–14, Magisk) handset over Wi-Fi LAN to your telephony/messaging bridge, from wireless-first quick start to 24/7 Linux/LXC deployment, industry personas, external booking webhooks, and FAQs.
Why Samsung phones over Wi-Fi solve South Korea's SIP barrier in 10 seconds.
In South Korea, obtaining a telecom SIP trunk is effectively restricted to registered business contracts — individual builders and small teams cannot easily plug Twilio or SIP voice tutorials into a Korean mobile number. Android Call Agent solves this by turning SIM-enabled rooted Samsung Android phones over Wi-Fi into live telephony bridges.
Run the AI agent brain on your server (PC, Linux, or Proxmox LXC), and place calls, answer calls, and reply to SMS/LMS/RCS over Wi-Fi through real 010 mobile numbers. No USB cable is needed during continuous operation, and callers simply dial or text a normal phone number.
--config files for independent inbound/outbound linesRather than a single-process multiplexer, each phone pairs 1:1 with its own flip4-call-agent --config <phone>.yaml gateway / agent process pair. For example, Phone #1 can handle office/clinic reception, Phone #2 bookings and cancellations, and Phone #3 outbound personal-assistant calls simultaneously.
# phone-a.yaml (Phone #1: reception) | phone-b.yaml (Phone #2: bookings)
bridge.host: "192.168.0.101" | bridge.host: "192.168.0.102"
gateway.port: 18780 | gateway.port: 18781
gateway.agent_name: "agent-phone-a" | gateway.agent_name: "agent-phone-b"
gateway.db_path: "data/phone-a.db" | gateway.db_path: "data/phone-b.db"
persona: { ...reception... } | persona: { ...bookings... }
# Run a 1:1 process pair per handset
uv run flip4-call-agent --config phone-a.yaml agent --mode start
uv run flip4-call-agent --config phone-a.yaml gateway
uv run flip4-call-agent --config phone-b.yaml agent --mode start
uv run flip4-call-agent --config phone-b.yaml gateway
| Port | Protocol | Direction | Purpose |
|---|---|---|---|
18765 |
HTTP / WebSocket (/events) |
Gateway → Phone | /health, /call/*, /sms/*, /audio/*, live call & SMS events |
18766 |
Framed TCP (!BI header + payload) |
Bidirectional | 16kHz 16-bit mono PCM (20ms = 640B) real-time telephony audio |
18780 |
HTTP (default 127.0.0.1) |
CLI / MCP → Gateway | Local control API (/health, /calls/*, /sms/*, /policy/*) |
18781 |
Streamable HTTP (/mcp, /healthz) |
Remote MCP → MCP Server | Remote agent hub transport (Bearer auth + allowed_hosts; use Caddy or Cloudflare Tunnel) |
Ensure both the Samsung handset and host build toolchain meet these versions.
shell / root access when prompted.javac -source 11 -target 11.platforms/android-34/android.jar, build-tools/34.0.0/d8, and platform-tools/adb under $HOME/Library/Android/sdk (macOS) or $HOME/Android/Sdk (Linux).>=3.11,<3.14) & uv: Install uv.LIVEKIT_URL, LIVEKIT_API_KEY, LIVEKIT_API_SECRET (default Realtime openai/gpt-realtime-2.1 and SMS LLM google/gemma-4-31b-it run via LiveKit Inference).voice_pipeline.mode: pipeline with direct Cartesia STT/TTS (CARTESIA_API_KEY, CARTESIA_VOICE_ID).Configure .env and config.yaml, deploy over Wireless Debugging (adb connect), and start the worker and gateway.
LIVEKIT_URL=wss://<YOUR_PROJECT>.livekit.cloud
LIVEKIT_API_KEY=<YOUR_LIVEKIT_API_KEY>
LIVEKIT_API_SECRET=<YOUR_LIVEKIT_API_SECRET>
BRIDGE_AUTH_TOKEN=<YOUR_64HEX_TOKEN>
# Optional (initial ADB deploy only): FLIP4_ADB_SERIAL=<PHONE_WIFI_IP>:<ADB_PORT>
mode: allinbound.mode, outbound.mode, and sms.inbound_reply_mode all ship set to disabled in config.example.yaml and deploy/config.lxc.example.yaml. For wireless operation, set bridge.host to your phone's Wi-Fi IP and keep bridge.auto_adb_forward: false, then switch modes to whitelist with only your test phone number in allowlist.
cp .env.example .env && cp config.example.yaml config.yamlCopy untracked config templates (.gitignore excludes both)uv syncCreate .venv and install locked dependenciesadb pair <PHONE_WIFI_IP>:<PAIR_PORT> && adb connect <PHONE_WIFI_IP>:<ADB_PORT>Connect via Android 12–14 Wireless Debugging (no USB cable needed)TOKEN="$(openssl rand -hex 32)" && adb -s <PHONE_WIFI_IP>:<ADB_PORT> shell "su -c 'printf %s \"$TOKEN\" > /data/local/tmp/flip4-bridge.token && chmod 600 /data/local/tmp/flip4-bridge.token'"Generate 64-char hex shared token and store on handset (match BRIDGE_AUTH_TOKEN in .env)export ADB_SERIAL="<PHONE_WIFI_IP>:<ADB_PORT>" BRIDGE_BIND_HOST="<PHONE_WIFI_IP>" BRIDGE_AUTH_TOKEN_FILE="/data/local/tmp/flip4-bridge.token"Target wireless ADB and enable LAN token auth (set ANDROID_JAR / D8_BIN on custom Linux paths)bash android-bridge/scripts/build_and_deploy.shCompile Java 11 → dex with d8 → push /data/local/tmp/flip4-bridge.dex → start root daemon on LAN with Bearer authuv run flip4-call-agent agent --mode startTerminal 1: start the LiveKit Voice Agent WorkerBRIDGE_AUTH_TOKEN="$TOKEN" uv run flip4-call-agent gatewayTerminal 2: start CallGateway and HTTP control API (:18780)For quick local 127.0.0.1 loopback testing over USB without LAN auth, omit BRIDGE_BIND_HOST and BRIDGE_AUTH_TOKEN_FILE, set ADB_SERIAL=<USB_SERIAL> for build_and_deploy.sh, and run bash android-bridge/scripts/verify_bridge.sh to verify /health, /audio/probe, WS /events, and TCP CTRL_PING.
/health, /sms/status, and callsVerify curl -s -H "Authorization: Bearer $TOKEN" http://<PHONE_WIFI_IP>:18765/sms/status (or http://127.0.0.1:18765/sms/status in loopback mode) returns "ok": true, "telephony_service_manager_ready": true, "sms_max_korean_bytes": 80, "lms_max_korean_bytes": 2000, and "lms_ready": true. Place a whitelisted test call, test barge-in and end_call, then inspect uv run flip4-call-agent calls --limit 10 and --detail <call_id>.
persona by IndustryAdapt clinics, law/tax offices, support desks, or booking shops purely in config.yaml.
The persona: section feeds both the voice assistant prompt (agent_worker.py) and the SMS auto-responder prompt (sms_responder.py) simultaneously.
business_name, office_address, secondary_address, representative_name, office_phone, sms_contact_phone, booking_url, info_urlphone_consultation_info, visit_consultation_info, reservation_guidance, business_summary, service_categories, faq_guidance, intake_fields_requiredassistant_intro, outbound_intro, out_of_scope_script, style, safety_guardrails, allowed_disclosure, forbidden_topicsvoice_pipeline.mode: realtime vs pipeline
openai/gpt-realtime-2.1 + gpt-4o-mini-transcribe (ko) model.deepgram/nova-3 or cartesia/ink-whisper STT + google/gemma-4-31b-it LLM + cartesia/sonic-3 TTS + silero VAD.organization vs personal Profiles · dry_run · Hard Blocksoutbound.default_persona_mode is organization (CallAssistant), while MCP make_call defaults to persona_mode="personal" (PersonalCallAssistant). In personal mode, only personal_persona is used, org identity and check_consultation_availability are excluded, and a caller name is included only if caller_identity is passed.dry_run: should_allow_outbound unconditionally blocks emergency numbers (112, 119, 911, 110, 1339), paid 060 lines, and <8-digit shortcodes (preserving 8-digit lines like 1588-XXXX) and cannot be disabled via PUT /policy/outbound. Rate limiting (max_calls_per_hour: 10, HTTP 429) and dry_run=True preflight checks ship built in.Engineered around Korean carrier UDH multipart issues and Samsung Chat+ providers.
SmsController.java measures outbound text using text.getBytes("EUC-KR"). Messages up to 80 bytes and 68 characters (1 part in SmsManager.divideMessage()) send via SmsManager.sendTextMessage() with automatic ISms Binder reflection fallback. Larger Korean messages (up to 2000B) skip UDH multipart SMS and instead encode a pure Java OMA-TS-MMS-ENC v1.2 M-Send.req binary PDU (MmsPduBuilder.java, UTF-8 text/plain single part), staged through content://mms/drm and sent as 1 LMS.
| Channel | Content URI | bridge_sms_id Offset |
Notes |
|---|---|---|---|
Standard SMS (sms) |
content://sms/inbox (type=1) |
0 + _id |
Standard Android SMS inbox |
Samsung Chat+ (rcs) |
content://im/chat (type=1) |
1,000,000,000 + _id |
Samsung Messages RCS text messages |
Long LMS / MMS (mms) |
content://mms/inbox (msg_box=1) |
2,000,000,000 + _id |
Reads body from content://mms/part with up to 2 delayed retries |
CallGateway deduplicates via a UNIQUE index on sms_messages.bridge_sms_id in data/calls.db. When ignore_shortcodes: true, only 10+ digit 010 mobile numbers are answered and automated messages containing [Web발신], 인증번호, OTP, 보안코드, or 본인확인 are ignored. Policy enforces max_outbound_per_hour (20), max_replies_per_sender_per_hour (5), and max_agent_sms_per_call (2).
Static DHCP lease, 64-char hex token auth, Magisk boot autostart, and systemd services.
192.168.0.100) for the handset MAC in your router.openssl rand -hex 32 and write it via Wireless Debugging (adb connect <PHONE_WIFI_IP>:<ADB_PORT>) or optional USB to /data/local/tmp/flip4-bridge.token (chmod 600) on the phone, and set BRIDGE_AUTH_TOKEN in /etc/flip4-call-agent/env. Non-loopback binds fail closed without a non-empty token.magisk_service_flip4_bridge.sh via wireless ADB (or USB) to /data/adb/service.d/99-flip4-bridge.sh (chmod 755). Thereafter, reboots wait for sys.boot_completed=1 and wlan0 IPv4 and launch com.flip4.bridge.Main with zero USB or ADB needed.ADB_SERIAL=<PHONE_WIFI_IP>:<ADB_PORT> bash android-bridge/scripts/enable_battery_protect.sh (or over USB) for continuous plugged-in safety.sudo useradd -r -s /usr/sbin/nologin flip4 || true
sudo mkdir -p /opt/flip4-call-agent /etc/flip4-call-agent /var/lib/flip4-call-agent
sudo chown -R flip4:flip4 /opt/flip4-call-agent /var/lib/flip4-call-agent
sudo rsync -a --exclude '.git' --exclude '.venv' ./ /opt/flip4-call-agent/
cd /opt/flip4-call-agent && sudo -u flip4 uv sync --no-dev
sudo cp deploy/config.lxc.example.yaml /etc/flip4-call-agent/config.yaml
# Set bridge.host to the phone's static IP and keep auto_adb_forward: false
# Write /etc/flip4-call-agent/livekit.env (LIVEKIT_*) and /etc/flip4-call-agent/env (BRIDGE_AUTH_TOKEN), chmod 600
sudo cp deploy/flip4-gateway.service deploy/flip4-agent.service deploy/flip4-mcp.service /etc/systemd/system/
sudo systemctl daemon-reload && sudo systemctl enable --now flip4-gateway.service flip4-agent.service
# Optional remote Streamable HTTP MCP (/mcp on :18781) behind deploy/caddy-mcp.example.caddy or Cloudflare Tunnel:
# sudo systemctl enable --now flip4-mcp.service
Authorization: Bearer <token>, TCP audio validates CTRL_AUTH (0x08), and remote MCP enforces MCP_AUTH_TOKEN + MCP_ALLOWED_HOSTS.booking_api & admin_webhook v1.0 ContractsJSON contracts for live availability lookup and post-call summary webhooks.
booking_api Real-Time Availability LookupWith booking_api.enabled: true, calls to check_consultation_availability(mode="phone"|"visit", date_hint) or schedule-related SMS queries issue GET <base_url>/api/consultation/availability?mode=phone (or visit). Responses are cached for cache_ttl_sec (default 60s), zero caller PII is sent, and timeouts fall back safely to persona.booking_url.
{
"mode": "phone",
"timeZone": "Asia/Seoul",
"from": "2026-12-07",
"to": "2027-01-03",
"days": {
"2026-12-07": ["10:00", "10:30", "14:00"],
"2026-12-08": [],
"2026-12-09": ["11:00", "11:30", "15:00", "15:30"]
}
}
admin_webhook (schema_version: "1.0")Setting ADMIN_WEBHOOK_URL and ADMIN_WEBHOOK_TOKEN in .env triggers a JSON POST after each call ends. Even when disabled or failing, data/calls.db always preserves the transcript and webhook_status (pending | sent | failed | skipped).
{
"schema_version": "1.0",
"call_id": "in-abc123",
"direction": "inbound",
"caller_number": "01012345678",
"contact_name": null,
"started_at": "2026-12-04T13:00:00+00:00",
"ended_at": "2026-12-04T13:01:12+00:00",
"duration_sec": 72.0,
"status": "completed",
"summary_ko": "통화유형: 수신 (72.0초) | 상대방: 01012345678 | 핵심내용: ...",
"intake_fields": {
"caller_name": "홍길동",
"callback_number": "01012345678",
"consultation_type": "phone",
"preferred_time": "오후 2시",
"inquiry_category": "상담·예약 문의"
},
"follow_up_needed": true,
"transcript": [
{
"speaker": "agent",
"text": "안녕하세요, 샘플 상담센터 AI 상담 도우미입니다...",
"created_at": "2026-12-04T13:00:02+00:00"
}
]
}
Six real-device edge cases and how the starter handles them.
*********** when a call turns ACTIVE on Samsung.One UI dumpsys shows the real number during RINGING and can mask it once answered. TelecomController.java and CallGateway._handle_active preserve the real caller number prewarmed during RINGING so whitelist, SQLite logging, and send_sms_to_caller still work. Unprewarmed masked ACTIVE calls are terminated for safety.
Korean carriers frequently drop or reorder UDH multipart SMS. Above 80B EUC-KR or 68 chars, the bridge switches automatically to 1 LMS PDU (M-Send.req). Check curl -s -H "Authorization: Bearer $TOKEN" http://<PHONE_WIFI_IP>:18765/sms/status (or http://127.0.0.1:18765/sms/status in loopback mode) for lms_ready: true, imms_binder_ready: true, and default_sms_sub_id >= 0.
build_and_deploy.sh fails inside d8 with an anonymous class error.Recent javac + build-tools 34.0.0 d8 can hit an NPE on InnerClasses attributes in anonymous inner classes (*$1.class). Keep all Java bridge classes using explicit private static final class declarations; both build_and_deploy.sh and pytest enforce zero *$[0-9]*.class outputs.
Check adb devices and set export ADB_SERIAL=<YOUR_ADB_SERIAL>, or configure FLIP4_ADB_SERIAL in .env and bridge.adb_serial in config.yaml. Wireless mode (auto_adb_forward: false) connects directly to bridge.host.
401 Unauthorized.Confirm the contents of /data/local/tmp/flip4-bridge.token on the phone match BRIDGE_AUTH_TOKEN with no extra whitespace or newlines, verify auth=enabled and wlan0 bind IP in /data/local/tmp/flip4-bridge.log, and verify Wi-Fi AP Isolation is disabled for TCP ports 18765 and 18766.
Check bridge.samsung_uplink_mode: "translation_tx_mute", enable bridge.mute_mic_during_call: true if needed, and tune gateway.aec_enabled: true with aec_stream_delay_ms between 80 and 140. Test non-call audio with POST http://127.0.0.1:18780/calls/test-tone ({"allow_probe_mode": true}) or GET http://<PHONE_WIFI_IP>:18765/audio/probe (or bash android-bridge/scripts/verify_bridge.sh in loopback mode).
uv run pytest -v: Verify all Python tests, Java d8 zero-anonymous-class checks, and JVM self-tests pass.end_call → uv run flip4-call-agent calls --detail <call_id>.inbound.mode and sms.inbound_reply_mode from whitelist to all or non_contacts when ready.