A Python-based AI phone agent for keiko.tv that handles customer service calls, manages contacts via SQLite, and integrates with FSM-generic for state-driven scheduling.
https://github.com/davidbmar/phone-agent-keiko-tv · private · shipped
This project implements an automated phone customer service agent. It combines a Python backend for call logic and contact management with a lightweight web interface. The system normalizes caller IDs, stores lead information in a local SQLite database, and uses an FSM (Finite State Machine) bridge to handle complex conversational states like scheduling, falling back to basic LLM responses if the FSM service is unavailable.
pip install -e . python -m phone_agent
flowchart TD
Caller[Inbound Call] --> Telephony[Telephony Gateway]
Telephony --> Server[Python Server]
Server --> ContactsDB[(SQLite Contacts DB)]
Server --> FSMBridge[FSM Bridge]
FSMBridge --> FSMGeneric[FSM-Generic Service]
FSMBridge --> LLM[Fallback LLM]
Server --> WebUI[Real-time Web UI]
Admin[Admin User] --> WebUI
The core logic is written in Python, utilizing `sqlite3` for persistent contact storage and `httpx` for asynchronous HTTP communication with external AI/FSM services. The entry point is a standard Python module (`__main__.py`) that launches a server. A minimal JavaScript snippet handles frontend authentication visibility. The architecture separates concerns into contact management (`contacts.py`), conversation bridging (`fsm_bridge.py`), and server orchestration.
sequenceDiagram
participant C as Caller
participant S as Phone Agent Server
participant DB as Contacts DB
participant B as FSM Bridge
participant F as FSM-Generic
C->>S: Initiate Call
S->>DB: Lookup/Normalize Phone Number
DB-->>S: Return Contact Info
S->>B: Process Conversation Input
alt FSM Available
B->>F: Send State/Context
F-->>B: Return Action/Response
else FSM Unavailable
B->>B: Fallback to Basic LLM
end
B-->>S: Return Spoken Response
S->>C: Play Audio Response
S->>DB: Update Lead Status/Notes
Deploy this as a backend service for handling inbound customer support calls. Use it to automatically capture lead details, normalize phone numbers for CRM consistency, and manage appointment scheduling conversations without human intervention. It is suitable for small-to-medium businesses needing 24/7 initial triage.