Self-Hosted Telegram Bot for Pi AI Agent Control

Minimalist Telegram interface to control Pi AI agent harness with shell execution and session switching

Updated: 5/22/2026
Difficulty
medium
Time
2-4h
Use Case
Remote control of self-hosted AI agent from mobile phone with direct shell execution and context preservation
Popularity
0 views

About this automation

Build a minimalist self-hosted Telegram bot that connects directly to a Pi AI agent harness, allowing you to switch sessions, task the agent from cron/at, and execute bash commands directly from Telegram. Intentionally stripped of features that bash or the LLM can handle better.

How to implement

1

Set up Pi AI agent harness with your custom configuration

2

Create Telegram bot via BotFather and obtain API token

3

Write TypeScript/Bun handler for Telegram messages

4

Implement session switching logic to preserve context across commands

5

Add cron/at integration to task agent from shell and receive Telegram responses

6

Implement bash execution handler with safety considerations

7

Compile to single binary and deploy on your infrastructure

8

Test session persistence and context management