How pricardok/agente-sdr-comercial works
This is a FastAPI commercial SDR agent that processes WhatsApp leads delivered through Chatwoot, qualifies them with an LLM, and replies or hands them to a human. The documented workflow includes webhook filtering, pause/duplicate checks, conversation memory, debounce, knowledge grounding, and handoff alerts. The graph includes the principal database and optional customer lookup. Some service implementation is only partially excerpted, so the README and source index support several documented links; unsampled internals are not inferred.
Main entry points: sdr_service.py SDR workflow · sdr_routes.py Webhook route · database_core.py Lead memory database · settings.py Runtime settings
Components 17
Webhook entry
- FastAPI app
app/main.py - Webhook route
app/routes/sdr_routes.py - Webhook schema
app/schemas/webhook.py
Conversation processing
- SDR workflow
app/services/sdr_service.py - Message debounce
app/services/debounce_service.py - Sales knowledge
knowledge - Human handoff tool
app/schemas/tools.py - Phone normalization
app/utils/normalizacao.py
Conversation state
- Lead memory database
app/database/database_core.py - Conversation records
app/models/conversa.py - Message records
app/models/mensagem.py - Runtime settings
app/config/settings.py - Optional customer lookup
app/database/database_core.py
External integrations
- LiteLLM gateway
- Chatwoot API client
app/services/chatwoot_service.py - Handoff alert service
app/services/alerta_service.py
Other components
- WhatsApp / Chatwoot
Connections 19
- WhatsApp / Chatwoot → Webhook route: sends events
README.md - FastAPI app → Webhook route: registers route
app/main.py - Webhook route → Webhook schema: validates payload
app/routes/sdr_routes.py - Webhook route → SDR workflow: dispatches event
app/routes/sdr_routes.py - Webhook route → Lead memory database: provides session
app/routes/sdr_routes.py - SDR workflow → Message debounce: buffers messages
README.md - SDR workflow → Sales knowledge: loads context
README.md - SDR workflow → LiteLLM gateway: requests response
README.md - SDR workflow → Human handoff tool: handles transfer tool
README.md - SDR workflow → Phone normalization: normalizes phone
app/services/sdr_service.py - SDR workflow → Lead memory database: reads and writes memory
app/services/sdr_service.py - Lead memory database → Conversation records: persists conversations
app/database/init_schema.py - Lead memory database → Message records: persists messages
app/database/init_schema.py - SDR workflow → Optional customer lookup: checks customer status
app/services/sdr_service.py - SDR workflow → Chatwoot API client: checks tags and sends
app/services/sdr_service.py - Chatwoot API client → WhatsApp / Chatwoot: calls REST API
app/services/chatwoot_service.py - SDR workflow → Handoff alert service: dispatches handoff alert
app/services/sdr_service.py - Runtime settings → Lead memory database: configures connection
app/database/database_core.py - Runtime settings → Optional customer lookup: configures optional connection
app/database/database_core.py