Metadata-Version: 2.4
Name: autodial
Version: 0.1.0
Summary: A self-hosted automated outbound dialer phone bot
Author: Autodial Maintainers
License: MIT
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: fastapi
Requires-Dist: uvicorn
Requires-Dist: python-dotenv
Requires-Dist: twilio
Requires-Dist: faster-whisper
Requires-Dist: aiohttp
Requires-Dist: numpy
Requires-Dist: pydantic

# Autodial PhoneBot

A self-hosted automated outbound dialer phone bot capable of using speech recognition and LLM to navigate IVRs and DTMFs, understand calls intelligently, process multiple calls concurrently, and broadcast messages.

## Features
- **Concurrent Calls**: Runs on FastAPI websockets handling multiple simultaneous Twilio Media Streams.
- **Transcripts**: Auto-generates local `call_logs/` JSON transcripts, tracking the context between user and AI continuously.
- **Fast Speech Recognition**: Utilizes `faster-whisper` dynamically processing audio chunks in real-time.
- **Intelligent Response**: Pipes transcribed data to an LLM via Ollama and outputs context-aware conversation responses natively handling IVR DTMF tone demands.
- **Message Broadcasting**: Enables dispatching multiple calls programmatically via the `/broadcast` REST Endpoint.
- **Local TTS**: Near-real-time vocal response generation via Piper TTS integration encoded gracefully to Twilio u-law compatibility standards over Websockets.

## Installation

You can install the pacakge directly from the source code via pip in editable mode:
```bash
pip install -e .
```

*Prerequisites Checklist:*
1. Have an active Ollama process serving the defined `LLM_MODEL`.
2. Have Piper executable in `PATH` natively, downloading its required onnx models (`PIPER_MODEL`) to the execution directory.

## Configuration

Make sure your target environment configures these necessary `.env` variables:
```
PORT=8000
OLLAMA_CHAT_URL=http://localhost:11434/api/chat
LLM_MODEL=llama3.2:3b
PIPER_MODEL=./en_US-lessac-medium.onnx
TWILIO_ACCOUNT_SID=...
TWILIO_AUTH_TOKEN=...
TWILIO_PHONE_NUMBER=...
```

## Running the System

Start the server using its PyPI distributed script bin:
```bash
autodial
```
Or use:
```bash
python -m autodial.server
```

### Endpoints
- `POST /dial`: Trigger single call
    - Body: `{"to_number": "+1...", "context": "...", "goals": "...", "keywords": "..."}`
- `POST /broadcast`: Broadcast to list of targets
    - Body: `{"numbers": ["..."], "message": "Direct message to play", "context": "...", "goals": "...", "keywords": "..."}`
    - *Note*: If `message` is provided, the bot plays it exactly once and hangs up immediately.
