Production-ready AI call agent service that integrates n8n -> application -> Plivo -> user. It supports configurable, per-client question flows, low-latency scripted prompts, and end-of-call summaries.
Features
- Config-driven question flow per client
- Preloaded greeting and scripted prompts
- Optional short acknowledgements before questions (configurable)
- Plivo call control with speech input
- Objection handling and interest scoring
- End-of-call summary + transcript delivery to n8n
- Optional per-turn transcript webhook to n8n
- Gemini audio generation for all prompts (no Plivo TTS)
- Optional Gemini live streaming mode (barge-in)
- Minimal logging at key integration points
Quick start
- python -m venv .venv
- source .venv/bin/activate
- pip install -r requirements.txt
- cp .env.example .env
- edit .env
- uvicorn app.main:app --host 0.0.0.0 --port 8000
n8n flow
- Import workflows from
n8n_flows/ - Start call webhook:
/webhook/fwai_start_call - End webhook:
/webhook/fwai_call_end - Turn webhook (optional):
/webhook/fwai_call_turn - Webhook URLs can be set per-client in the client config (preferred), or in
.envas defaults.
Plivo setup
- Set PUBLIC_BASE_URL in .env to your public HTTPS URL (e.g., ngrok).
- The app uses PUBLIC_BASE_URL for Plivo callbacks.
- Supported callback paths:
/plivo/callbackand/plivo/hangup.
Gemini audio modes
AUDIO_MODE=gemini: pre-generated Gemini audio played with<Play>(no latency during call).AUDIO_MODE=gemini-live: Gemini Live streaming over WebSocket with barge-in.AUDIO_STRICT=trueensures all prompt audio is generated before the call starts (zero latency during call).USE_GEMINI_AUDIO_CACHE=trueandPREWARM_ON_STARTUP=trueare recommended for low latency.
Acknowledgements (optional)
- Set
ack_enabled=trueand addacknowledgements/ack_rulesin the client config. - The agent will say a short acknowledgement before the next question while staying in the scripted flow.
- In strict audio mode, acknowledgement + question combinations are pre-generated for zero latency.
Notes
- API keys are loaded via environment variables only. Do not commit secrets.
- For ultra-low latency, keep prompts scripted and preloaded in config.