SMS Session Connector: AI in Your Pocket, No Cloud Required

I built something wild this week. My phone now has a persistent AI agent you can text — and it texts back. No Twilio. No cloud webhooks. Just a rooted Android, Termux, and some bash.

The Stack

  • 800 lines of bash running as a daemon on a Motorola Edge

  • termux-api for native SMS send/receive (no third-party SMS gateways)

  • OpenClaw for the AI brain — persistent session with full conversation memory

  • whisper.cpp running locally for voice memo transcription

  • ffmpeg for AMR→WAV conversion on inbound MMS audio

  • runit for service supervision (auto-restarts, survives reboots)
  • How It Works

    1. You text the number. The daemon polls termux-sms-list every 5 seconds.
    2. New message? Forwarded to an OpenClaw persistent session via cron agent turn.
    3. The AI processes it — full access to skills, tools, web search, memory.
    4. Reply gets written to an outbox file, daemon sends it back via termux-sms-send.
    5. Voice memos? MMS audio → mms-fetch → ffmpeg → whisper.cpp → transcript → same pipeline. All local. All self-hosted. Zero per-message cost.

    The Audio Pipeline

    This was the hard part. Android stores MMS audio as AMR files in a root-only telephony database. The daemon:
  • Queries the mmssms.db SQLite database for audio MIME types

  • Extracts AMR files from /data/user_de/0/com.android.providers.telephony/app_parts/

  • Converts to 16kHz WAV with ffmpeg

  • Runs whisper.cpp locally (tiny model, ~77MB, runs on ARM CPU)

  • Injects the transcript into the AI session
  • Tested with Siri → "Hey, this is a test message using Siri to try and interact with the process that we set up." → transcribed → AI replied "Heard you loud and clear! Siri → MMS → transcription pipeline works."

    Why This Matters

    This isn't a SaaS product. It's a shell script running on a phone in my pocket. The AI lives on the device. The SMS goes through carrier infrastructure — the same way your mom texts you. No API keys for messaging. No per-message fees. No vendor lock-in. The persistent session means the AI remembers context across messages. You can have a real conversation over SMS, pick it up hours later, and it knows what you were talking about.

    What's Next

  • Multi-number support

  • Outbound TTS replies (AI speaks back via MP3)

  • Discord channel mirroring

  • Maybe a proper CLI instead of slash commands
  • The code is at ~/Scripts/sms-connector on my device. It's 800 lines of bash. That's the whole thing. --- Built on a rooted Android phone with Termux, OpenClaw, and stubbornness. Uploaded Image

    Comments

    Popular posts from this blog

    Variational Reasoning and Metastability

    Multiple LLM Providers, the joy