An AI receptionist on a Raspberry Pi
My phone line is now answered by a Grok voice agent. It takes a message, reads it back, says goodbye and hangs up — and a minute later the message and full transcript are in my inbox. The only hardware is a Raspberry Pi 4.
How a call flows
The audio never touches the Pi. Telnyx and xAI talk to each other directly; the Pi only receives a short "incoming call" notification, opens a WebSocket to steer that call, and sends the email afterwards. That's why a Pi 4 is more than enough.
The pieces
| Part | Role | Cost |
|---|---|---|
| Telnyx | Phone number and SIP trunk | ~$1/mo + fractions of a cent per minute |
| xAI Voice Agent API | The voice: speech in, Grok, speech out | Per minute of conversation |
| Raspberry Pi 4 | A few hundred lines of Python | A few watts |
| Cloudflare Tunnel | Public HTTPS address with no open router ports | Free |
| Domain | A stable hostname for the webhook (and this site) | ~$10/yr |
Giving the agent hands
The agent gets two tools. take_message saves the caller's name, callback number and message — but only after reading it back and hearing "yes". end_call is used after saying goodbye; the Pi waits for the goodbye to finish playing, then asks xAI to hang up. Everything else is plain-English instructions in a text file I can edit without restarting anything.
Keeping it locked down
- The tunnel exposes exactly one path; everything else returns 404.
- Every webhook is signature-checked; unsigned requests get 401.
- xAI only accepts calls from Telnyx's signaling IPs, and the trunk's outbound side is locked with unused credentials.
- API keys live only on the Pi, readable by a dedicated service user.
Things that tripped me up
- The first call never left Telnyx. A brand-new number was attached to a default Telnyx app, which answered and hung up after 12 seconds. The SIP trace made it obvious: a 0.6-second "answer" came from Telnyx's own media server.
- Agents paraphrase. Asked to greet "as described", Grok produced a greeting that contradicted itself. Sending the exact sentence fixed it.
- Email is harder than voice. Hotmail no longer allows password-based SMTP at all, and Gmail app passwords weren't available on my account. iCloud Mail worked.