Innovative Telegram AI Agent: Memory & Self-Hosting SolutionInnovative Telegram AI Agent: Memory & Self-Hosting Solution
The network for creativity
Join 1.25M professional creatives like you
Connect with clients, get discovered, and run your business 100% commission-free
Creatives on Contra have earned over $150M and we are just getting started
Telegram AI Agent with Memory, Tools, and Android Self-Hosting
Bzhela started as an experimental Telegram AI agent but evolved into a full research project focused on long-term memory, controlled context, and autonomous infrastructure. The goal was to build a context-aware assistant that tracks conversation flow and interacts with real-world tools without losing coherence in an active group chat.
The core of the system was a custom memory architecture. To prevent context collapse, I built a rolling strategy where older messages were compressed into a summary while fresh messages remained raw. I used Redis for short-term history and Pinecone for long-term fact retrieval. The agent actively extracted and managed facts, applying time-to-live limits to temporary memories so the database stayed clean.
This setup allowed the agent to be proactive rather than purely reactive. It operated with practical integrations tied to daily life. The agent checked local power outage schedules, managed Google Calendar events, and interacted bidirectionally with an iPhone via Shortcuts. It could trigger phone-side scenarios, like setting alarms or sending warnings based on battery levels.
The infrastructure was deliberately unconventional. Instead of a standard cloud server, the agent ran on a self-hosted Android phone without root. I set up a runtime using Termux, proot Ubuntu, and Node.js, managed by PM2. Cloudflare Tunnel ensured secure remote access. This gave the agent physical survivability via a power bank and access to real-world network signals.
Over several months, the system maintained a stable context, managing around 150 compressed facts and proactively messaging based on real-world triggers. It proved that an AI agent can act as a reliable, system-level tool rather than just a simple chatbot wrapper.
Key technical aspects: - Custom memory stack using Pinecone and Redis - Rolling context and automated chat summarization - Event-driven proactive messaging - Integrations with Google Calendar, webhooks, and iOS Shortcuts - Self-hosted Android runtime with Termux and Cloudflare Tunnel
Post image
Post image
Post image
Post image
Anas's avatar
The best part is how the agent connects memory, tools, and proactive triggers into one working system instead of just replying to messages.
Shahwaiz's avatar
Building rolling memory with Redis + Pinecone on a self-hosted Android stack is serious agent engineering → this goes far beyond a typical “Telegram chatbot.”
Back to feed
The network for creativity
Join 1.25M professional creatives like you
Connect with clients, get discovered, and run your business 100% commission-free
Creatives on Contra have earned over $150M and we are just getting started