telegram
npx machina-cli add skill shane9coy/Telegram-Bot-Easy/telegram --openclawTelegram Skill
Auto-activate for Telegram message sending, daemon control, or bot configuration.
Setup Instructions (For CLI Agents)
When helping the user set up the Telegram bot, follow these steps:
Step 1: Install Dependencies
pip install -r requirements.txt
Step 2: Create Environment File
Copy the template and help the user fill in credentials:
cp .env.example .env
Required credentials (user must obtain):
| Credential | How to Get |
|---|---|
TELEGRAM_BOT_TOKEN | Message @BotFather on Telegram, use /newbot |
TELEGRAM_BOT_USER_ID | Message @userinfobot on Telegram |
TELEGRAM_API_ID | Go to https://my.telegram.org → API Development Tools |
TELEGRAM_API_HASH | Go to https://my.telegram.org → API Development Tools |
Step 3: Create Logs Directory
mkdir -p logs
Step 4: Start the Bot
python telegram_listener.py --daemon
Step 5: Verify Setup
python telegram_listener.py --status
Daemon Control
| What | Command |
|---|---|
| Start listener | /telegram start |
| Stop listener | /telegram stop |
| Status + PID | /telegram status |
| Sleep (alerts only) | /telegram sleep |
| Wake (full response) | /telegram wake |
| View logs | /telegram logs |
Send Messages
Command 'telegram' (see below for command content) send "Your message here"
Command 'telegram' (see below for command content) brief # Send morning briefing now
Command 'telegram' (see below for command content) alert "msg" # System alert notification
Architecture
Two-tier — daemon is standalone Python, cannot call Claude MCP directly:
| Tier | Mechanism | Commands |
|---|---|---|
| Direct | Pure Python + API calls | tasks, goals, weather, status |
| Queue | Write to /tmp/telegram_agent_queue.json | complex queries |
Key Files
- Script:
telegram_listener.py+telegram_helpers.py - PID:
/tmp/telegram_listener.pid - State:
/tmp/telegram_listener_state.json - Logs:
logs/telegram_listener.log - Queue:
/tmp/telegram_agent_queue.json - Template:
templates/helper_template.py
Config (user_profile.json → telegram)
{ "chat_id": null, "notifications_enabled": true, "morning_brief": true,
"task_reminders": true, "goal_checkin_time": "20:00", "always_listening": true }
Building New Integrations
Use the telegram-builder skill for detailed guidance on adding new commands and services.
Quick Pattern
-
Add helper function in
telegram_helpers.py:def get_my_service(query=None): """Fetch data from your API.""" # Your implementation return "**My Service**\nResult here" -
Import in
telegram_listener.py:from telegram_helpers import get_my_service -
Add command handler in
route_command():if lower.startswith("/myservice"): query = text.split(maxsplit=1)[1] if len(text.split()) > 1 else None return get_my_service(query)
Template Reference
See templates/helper_template.py for a complete integration example.
Built-in Bot Commands
The user can send these commands directly to their bot:
Tasks & Goals
| Command | Action |
|---|---|
/tasks | Today's tasks |
add task: ... | Add a task |
done: ... / done 1 | Complete a task |
/goals | Active goals |
add goal: ... | Add a goal |
/progress | Today's stats + streak |
System
| Command | Action |
|---|---|
/help | Full command menu |
/status | Listener + system health |
/weather | Current weather |
sleep / goodnight | Enter sleep mode |
wake / good morning | Exit sleep mode |
Scheduled Alerts
Configured in user_profile.json → telegram:
| Time | Alert | Config Key |
|---|---|---|
| 8:00 AM | Morning brief (weather, tasks, goals) | morning_brief: true |
| 8:00 PM (default) | Evening check-in (completed, pending, streak) | goal_checkin_time: "20:00" |
Source
git clone https://github.com/shane9coy/Telegram-Bot-Easy/blob/main/.kilocode/skills/telegram/SKILL.mdView on GitHub Overview
Telegram Skill automates an always-listening Telegram daemon to send messages, manage the task/goal bot, and configure scheduled alerts. It enables you to start/stop the listener, deploy bot commands, and tailor notifications from a single interface. This integration keeps your team updated with timely messages and reminders.
How This Skill Works
It runs as a standalone Python daemon that can be controlled via Telegram commands or scheduled checks. The system uses telegram_listener.py and telegram_helpers.py, with a lightweight queue at /tmp/telegram_agent_queue.json to handle complex queries. Built-in bot commands expose tasks, goals, and status, enabling automated messaging and alerts.
When to Use It
- Send a message or briefing through your Telegram bot.
- Start, stop, or check the status of the Telegram daemon.
- Configure or adjust task and goal reminders.
- Receive system alerts or scheduled notifications.
- Query tasks, goals, or status via built-in bot commands.
Quick Start
- Step 1: Install dependencies with pip install -r requirements.txt.
- Step 2: Create and fill .env with TELEGRAM_BOT_TOKEN, TELEGRAM_BOT_USER_ID, TELEGRAM_API_ID, TELEGRAM_API_HASH.
- Step 3: Start the daemon and verify status: python telegram_listener.py --daemon then python telegram_listener.py --status.
Best Practices
- Install dependencies with pip install -r requirements.txt.
- Create a proper .env file with TELEGRAM_BOT_TOKEN, TELEGRAM_BOT_USER_ID, TELEGRAM_API_ID, and TELEGRAM_API_HASH.
- Configure always_listening and reminder times in user_profile.json.
- Verify setup using python telegram_listener.py --status.
- Monitor logs in logs/telegram_listener.log and rotate logs regularly.
Example Use Cases
- Send a daily briefing through the bot at morning time.
- Push a system alert using the alert command to the configured chat.
- Check today’s tasks and goals with /tasks and /goals.
- Pause alerts with /telegram sleep and resume with /telegram wake.
- View daemon status and PID with /telegram status.