How revolutionarybukhari/ai-calling-agent works
This is a Flask-based AI calling agent for inbound and outbound mental-health conversations. The documented voice loop is: a caller reaches Twilio, Flask routes call events, speech is transcribed by Twilio and submitted to the chatbot, the response is synthesized to audio, and Twilio plays it while gathering the next utterance. Persistent chat history and appointment operations form a supporting data branch. README claims Pinecone and STT capabilities, but no implementation for Pinecone or independent STT appears in the supplied tree/excerpts; speech capture is represented by Twilio Gather. Edges are limited to visible calls or README-documented capabilities.
Main entry points: app.py Speech Capture · chatbot.py Chat Responses · twilio_api.py Twilio Call Handling · agent_tools.py History and Booking
Components 14
Call Control
- Flask API
app.py - Twilio Call Handling
modules/twilio_api.py - Speech Capture
app.py - Twilio
- WhatsApp Sender
modules/sender.py
Conversation
- Chat Responses
modules/chatbot.py - Agent Responses
modules/chatbot.py - OpenAI
- Pinecone
Persistence
- History and Booking
modules/agent_tools.py - MongoDB Records
modules/mongodb.py
Speech Output
- Audio Synthesis
modules/tts.py - ElevenLabs
Other components
- Caller
Connections 16
- Caller → Flask API: sends call request
README.md - Flask API → Twilio Call Handling: routes inbound call
app.py - Flask API → Speech Capture: handles speech post
app.py - Twilio Call Handling → MongoDB Records: checks caller history
modules/twilio_api.py - Twilio Call Handling → Twilio: starts outbound call
modules/twilio_api.py - Twilio → Speech Capture: posts recognized speech
app.py - Speech Capture → Chat Responses: requests reply
app.py - Chat Responses → OpenAI: generates response
modules/chatbot.py - Speech Capture → Audio Synthesis: synthesizes reply
app.py - Audio Synthesis → ElevenLabs: requests audio
modules/tts.py - Speech Capture → Twilio: returns playback instructions
app.py - Agent Responses → History and Booking: loads and saves history
modules/chatbot.py - History and Booking → MongoDB Records: reads and writes records
modules/agent_tools.py - Chat Responses → Agent Responses: alternate response path
modules/chatbot.py - Chat Responses → Pinecone: queries vectors
- Caller → WhatsApp Sender: receives WhatsApp message