AI agent that emails, texts, and calls customers – one API, shared context Telnyx published an open-source Python sample, omnichannel-ai-agent, that lets a single Claude tool-calling agent proactively email, text, and call customers through three Telnyx APIs — Email (POST /v2/email_messages), Messaging (POST /v2/messages), and Call Control (POST /v2/calls) — using one TELNYX_API_KEY. The Flask app stores persistent cross-channel conversation context in SQLite and handles webhook events including call.answered, call.speak.ended, call.hangup, message.received, and email.received, with Claude selecting email for formal acknowledgments, SMS for quick updates, and voice for complex resolution. Setup requires TELNYX_API_KEY, ANTHROPIC_API_KEY, TELNYX_FROM_NUMBER, TELNYX_EMAIL_FROM, and CONNECTION_ID, with MESSAGING_PROFILE_ID optional. | name | omnichannel-ai-agent | |---|---| | title | Omnichannel AI Agent | | description | One AI agent that proactively emails, texts, and calls customers using Claude tool-calling, Telnyx Email/SMS/Voice APIs, and SQLite for persistent cross-channel context. | | language | python | | framework | flask | | telnyx products | | | channel | | | Email | Messaging | Voice | Call Control | | email | sms | voice | One AI agent that proactively emails, texts, and calls customers. Claude API decides which channel to use via tool-calling. Telnyx handles Email, SMS, and Voice delivery. SQLite stores persistent cross-channel conversation context. Telnyx is an AI Communications Infrastructure platform — email, messaging, voice, and AI on one private, global network. This sample uses three Telnyx APIs Email, Messaging, Call Control from a single API key, demonstrating unified omnichannel communication. - Send Email : POST /v2/email messages — API reference https://developers.telnyx.com/api/email/send-email - Send Message : POST /v2/messages — API reference https://developers.telnyx.com/api/messaging/send-message - Create Call : POST /v2/calls — API reference https://developers.telnyx.com/api/call-control/create-call - Speak : POST /v2/calls/{call control id}/actions/speak — API reference https://developers.telnyx.com/api/call-control/speak - Hangup : POST /v2/calls/{call control id}/actions/hangup — API reference https://developers.telnyx.com/api/call-control/hangup This app handles these webhook events: - call.answered — Call connected, app speaks the AI-generated message - call.speak.ended — TTS playback finished, app hangs up - call.hangup — Call ended - message.received — Inbound SMS reply from customer - email.received — Inbound email reply from customer Claude API AI Brain │ Tool-calling decides which channel to use │ ┌────┴────┐ │ Flask │ │ app.py │ │ │ ┌─────┤ Context ├─────┐ │ │ SQLite │ │ │ └────┬────┘ │ │ │ │ Email API Messaging Call Control POST /v2/ POST /v2/ POST /v2/ email messages messages calls │ │ │ ▼ ▼ ▼ Customer Customer Customer inbox phone phone The AI agent receives a customer scenario, retrieves the full cross-channel conversation history from SQLite, and uses Claude's tool-calling to decide the next action. Claude chooses email for formal acknowledgments, SMS for quick updates, and voice for complex resolution — each message references previous interactions across channels. Copy .env.example to .env and fill in: | Variable | Type | Example | Required | Description | Where to get it | |---|---|---|---|---|---| | TELNYX API KEY | string | KEY0123456789ABCDEF | yes | Telnyx API v2 key | Portal https://portal.telnyx.com/api-keys · CLI: telnyx auth https://developers.telnyx.com/development/cli | | ANTHROPIC API KEY | string | sk-ant-api03-... | yes | Claude API key | Anthropic Console https://console.anthropic.com | | TELNYX FROM NUMBER | string | +15551234567 | yes | Telnyx phone number SMS + Voice | Portal https://portal.telnyx.com/numbers/my-numbers | | TELNYX EMAIL FROM | string | agent@yourdomain.com | yes | Verified sender email | Portal https://portal.telnyx.com/email | | MESSAGING PROFILE ID | string | 40017b7e-... | no | Messaging profile ID | Portal https://portal.telnyx.com/messaging/profiles | | CONNECTION ID | string | 1494404757140276705 | yes | Call Control connection ID | Portal https://portal.telnyx.com/call-control/applications | | PORT | integer | 5000 | no | HTTP server port | — | | DB PATH | string | conversations.db | no | SQLite database path | — | git clone https://github.com/team-telnyx/telnyx-code-examples.git cd telnyx-code-examples/omnichannel-ai-agent-python pip install -r requirements.txt python demo/demo server.py The demo walks through a billing dispute scenario: the agent sends an email, follows up via SMS, then calls the customer — all with shared context. No Telnyx or Claude credentials required. git clone https://github.com/team-telnyx/telnyx-code-examples.git cd telnyx-code-examples/omnichannel-ai-agent-python cp .env.example .env ← fill in your credentials pip install -r requirements.txt python app.py starts on http://localhost:5000 Trigger the agent: curl -X POST http://localhost:5000/agent/run \ -H "Content-Type: application/json" \ -d '{ "customer": { "id": "cust 001", "name": "Sarah Chen", "email": "sarah@example.com", "phone": "+15551234567" }, "scenario": "Customer is disputing a $147.50 charge on their September statement." }' 1. Expose your local server: ngrok http 5000 2. Copy the HTTPS URL and configure in Telnyx Portal https://portal.telnyx.com : - Call Control Application → Webhook URL → https://