# Build Your Own Open-Source Dots with Pi and Telegram

## Executive summary

This tutorial demonstrates how to build open-source, always-on AI agents, inspired by OpenAI's 'dots' concept. Using a VPS or local machine (like a DGX Spark), the system utilizes a message gateway architecture (inspired by Hermes and OpenClaw) to allow specialized agents (e.g., personal assistant, research agent) to be accessible from multiple platforms, specifically Telegram. The core components include agent workspaces, custom skills (like Google Workspace CLI access), and persistent session routing managed by a local SQLite database.

## Key takeaways

- Agent Architecture: Each agent is contained within its own directory, defining its specific tools, skills, and context via an `agents.mmd` file. This allows for specialized, isolated workspaces (e.g., a research agent vs. a personal assistant).
- Skills and Tooling: Agents can be equipped with skills, such as `firecroll pars`, `firecroll scrape`, and access to the Google Workspace CLI, enabling tasks like reading emails, summarizing messages, and creating calendar events.
- Message Gateway Implementation: The `pi-gateway` acts as a background process, constantly listening to multiple platforms (demonstrated with Telegram). It uses a local SQLite database to manage sessions, ensuring incoming messages are correctly routed to the specific agent's workspace and session.
- Setup Process: The gateway is installed using `uv tool install pi-gateway`. Agents are initialized using `pi gateway` commands, requiring the Telegram BotFather token and the user's unique ID for secure operation.

## Technical details

- Agent Persistence and Hosting: Agents must run on an 'always-on' machine (e.g., VPS, home desktop, DGX Spark) to maintain continuous availability and session state.
- Core Components: The system relies on a message gateway that uses a local SQLite database to store session information, linking the source (e.g., Telegram) to a specific agent's directory and session.
- Agent Context Management: Agent context is defined in an `agents.mmd` file, which provides the agent with its system prompt, role, and available tools (skills).
- Technical Commands: Key commands include: `npx skills add` (to add skills), `pi gateway` (to initialize the gateway), and `pi gateway start -i <instance_name>` (to start a specific agent instance).

## Practical implications

- Build highly specialized, open-source AI agents that function like personal assistants or research tools.
- Implement multi-platform communication by connecting a single agent workspace to various APIs (e.g., Telegram, WhatsApp, Slack).
- Understand the architecture of persistent, stateful AI agents using message gateways and local session routing.

## Topics

AI Agents, Message Gateways, Open-Source AI, Google Workspace Integration, System Architecture, pi-gateway, Google Workspace CLI, SQLite, Telegram BotFather

Source: https://www.youtube.com/watch?v=HU03WDFB_tQ
