Skip to main content
Glama
README.md
# PressZero

> **Stop mashing `0`.** Named after the universal instinct of hitting zero to escape automated phone menus — PressZero is an open-source outbound AI phone caller and **MCP server** powered by the **Gemini Live API** and **Twilio Media Streams**.

Give it a phone number, a goal, and an optional brief — it dials out, navigates automated IVR phone trees with in-band DTMF tones, waits silently on hold, talks naturally to human reps with real-time interruption (barge-in), and saves full speaker-labeled transcripts + structured summaries to `logs/`.

## Features

- **Native Speech-to-Speech (Gemini Live API):** Direct audio streaming (`8 kHz μ-law` ↔ `16/24 kHz PCM`) with no STT → LLM → TTS cascade latency.
- **Automatic IVR Navigation:** Synthesizes clean in-band DTMF keypad tones (`0–9`, `*`, `#`, `w` pause) via the `send_dtmf` tool.
- **Hold Patience & Barge-In:** Stays silent during hold music/announcements and immediately clears outbound audio when interrupted.
- **Zero-Config Tunneling:** Automatically spins up a free Cloudflare Quick Tunnel (`cloudflared`) per call — or use your own `PUBLIC_URL`.
- **Automatic Call Logs:** Saves every call as both Markdown (`logs/<timestamp>_<callId>.md`) and JSON (`logs/<timestamp>_<callId>.json`).
- **Universal MCP Server:** Zero-dependency stdio MCP server (`src/mcp_server.js`) so Claude Code, Cursor, Antigravity, Windsurf, or any MCP client can place calls and inspect logs as native tools.

## Architecture

```text
CLI / MCP Client
   └─▶ src/call.js
         ├─▶ cloudflared Quick Tunnel (HTTPS/WSS) ──▶ Twilio TwiML & Media Streams (8kHz μ-law)
         └─▶ src/server.js + src/gemini_bridge.js
               ├─▶ src/audio.js (μ-law ↔ PCM resampling + DTMF tone synthesis)
               └─▶ Gemini Live API WebSocket (24kHz native audio + transcription + tools)
```

## Prerequisites

1. **Node.js 20+**
2. **Google AI Studio API Key** ([aistudio.google.com/apikey](https://aistudio.google.com/apikey)) with access to `gemini-2.5-flash-native-audio-latest`.
3. **Twilio Account** ([console.twilio.com](https://console.twilio.com)):
   - **Upgrade from Free Trial** if you want to dial arbitrary numbers (Trial accounts only allow calling Verified Caller IDs and restrict call parameters).
   - Complete Twilio's **Trust Hub Primary Compliance Profile** if prompted for newly upgraded accounts.
   - Obtain either a **Twilio Voice phone number** (~$1.15/mo) or add a **Verified Caller ID** (e.g. a Google Voice number) for `TWILIO_FROM_NUMBER`.
4. **`cloudflared`** (for free automatic tunnels — skip if you provide `PUBLIC_URL`):
   - **macOS (Homebrew):** `brew install cloudflared`
   - **macOS (direct binary, Apple Silicon):**
     ```bash
     curl -fSL https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-darwin-arm64.tgz -o /tmp/cloudflared.tgz
     tar -xzf /tmp/cloudflared.tgz -C /tmp && mv /tmp/cloudflared ~/.local/bin/cloudflared
     ```
   - **Linux / Windows:** See [Cloudflare cloudflared releases](https://github.com/cloudflare/cloudflared/releases).

## Quick Setup

```bash
git clone https://github.com/MattChanTK/presszero.git
cd presszero
npm install
cp .env.example .env
```

Edit `.env` with your credentials:

```env
GEMINI_API_KEY=your_gemini_api_key_here
TWILIO_ACCOUNT_SID=ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
TWILIO_AUTH_TOKEN=your_twilio_auth_token_here
TWILIO_FROM_NUMBER=+15551234567
CALLER_NAME=Alex
GEMINI_VOICE=Charon
```

Verify the audio codec/DTMF self-test and run a dry-run (no call placed):

```bash
npm run test-audio
node src/call.js \
  --to "+15551234567" \
  --goal "Check Saturday business hours and whether walk-ins are accepted" \
  --dry-run
```

## CLI Usage

```bash
node src/call.js \
  --to "+15551234567" \
  --goal "Ask for a price quote and next available appointment" \
  --context-file ./brief.md \
  --caller-name "Alex" \
  --voice Charon \
  --max-minutes 30
```

### Options

| Flag | Description | Default |
| :--- | :--- | :--- |
| `--to <E.164>` | Destination phone number (required, e.g. `+15551234567`) | — |
| `--goal <text>` | Clear objective for the AI caller (required) | — |
| `--context <text>` | Inline reference facts (only shared if asked) | `""` |
| `--context-file <path>` | Path to a Markdown/text brief file | — |
| `--caller-name <name>` | Name the AI is calling on behalf of | `CALLER_NAME` or `"the caller"` |
| `--voice <name>` | Gemini Live voice (`Charon`, `Kore`, `Aoede`, `Puck`, `Fenrir`) | `GEMINI_VOICE` or `Charon` |
| `--model <name>` | Gemini Live model | `gemini-2.5-flash-native-audio-latest` |
| `--max-minutes <num>` | Safety hangup timeout in minutes | `30` |
| `--public-url <url>` | Custom public HTTPS URL (skips `cloudflared`) | `PUBLIC_URL` or auto-tunnel |
| `--dry-run` | Validate config & print system prompt without dialing | `false` |

### Example `brief.md`

```markdown
# Reference Details (ONLY share if asked)
- Name: Alex Rivera
- ZIP Code: 98101
- Callback Number: (555) 123-4567
- Preferred Days: Tuesday or Thursday mornings

# Guardrails
- Do not share payment details or authorize any charges.
- Ask for a confirmation or reference number before hanging up.
```

## MCP Server (Use From Any AI Agent)

`src/mcp_server.js` exposes three native MCP tools over stdio:

- `place_phone_call` — Dial an outbound call and return the saved transcript & summary
- `list_call_logs` — List recent calls with timestamps, targets, goals, and summaries
- `read_call_log` — Read the full speaker-labeled Markdown transcript for a `call_id`

### Claude Code
```bash
claude mcp add --scope user presszero -- node /absolute/path/to/presszero/src/mcp_server.js
```

### Cursor / Windsurf / Claude Desktop / Antigravity
Add to your MCP config (`~/.cursor/mcp.json`, `claude_desktop_config.json`, or plugin `mcp_config.json`):
```json
{
  "mcpServers": {
    "presszero": {
      "command": "node",
      "args": ["/absolute/path/to/presszero/src/mcp_server.js"]
    }
  }
}
```
*(If your GUI client doesn't inherit your shell `PATH`, use the absolute path to `node`, e.g. `/opt/homebrew/bin/node` or `~/.local/bin/node`.)*

## Estimated Cost

- **Twilio Voice + Media Streams:** ~\$0.018/min (~\$0.014/min outbound US voice + ~\$0.004/min Media Streams)
- **Gemini Live API:** ~\$0.005–\$0.006/min audio input + ~\$0.02/min audio output *while speaking* (near \$0 output while silent on hold)
- **Cloudflare Quick Tunnel:** \$0
- **Typical 10-minute call:** ~\$0.25–\$0.40 total

## Safety & Compliance

- **Always confirm before dialing** when driving this tool from an AI agent.
- **Never put SSNs, passwords, or full card/bank numbers** in `--context` or brief files.
- **Call recording / transcription laws:** Ensure you comply with local one-party or two-party consent laws when logging transcripts.

## License

[MIT](LICENSE)