An AI assistant for your telephone line.
Technologies used:
- FreePBX 17.0.24 (Asterisk 22.6.0)
- FastAPI
- Vosk STT
- Google TTS
- Gemini 3.0
- langChain
- Redis
- Green-API (WhatsApp)
- Home Assistant
The AI will decide on what the caller wants and take one of the following actions:
- Forward call to Voicemail
- Forward call to Mobile Phone
- Take a WhatsApp Message and send to a number
- Take and schedule a meeting appointment
- Take a message and send to email
- Respond to a greeting
- Toggle the Light Switch via Home Assistant
- Respond to any other question
The AI will request a date, time, meeting type (online, physical), email address and physical address through a series of questions. Once all the data is gathered, the final details are read back to the caller.
- Copy into /var/lib/asterisk/agi-bin/ai
- Create a Custom Destination: ai-entry,s,1
- Add the following to your /etc/asterisk/extensions_custom.conf
[ai-entry]
exten => s,1,NoOp(AI Entry Point)
same => n,Progress()
same => n,AGI(ai/ai_answer.py,${CALLERID(num)},${CALLERID(name)})
same => n,Hangup()
-
Reload your Dial Plans: asterisk -rx "dialplan reload"
-
ensure you have the following variables set in a local .env file:
GEMINI_API_KEY - for the llm HA_URL, HA_TOKEN - for HomeAssistant WA_TOKEN, WA_MOBILE, WA_INSTANCE - for WhatsApp MOBILE_NUM - for forward to mobile SMTP_SERVER, SMTP_PORT, SMTP_USER, SMTP_PASS - for email and meetings
-
Run the app.py (FastAPI) with uvicorn in a separate process (or separate machine):
uvicorn app:app --host 127.0.0.1 --port 8000 -
Use your Custom Destination in an IVR or elsewhere.
Real-time chat (audio streaming)