Get the FREE Ultimate OpenClaw Setup Guide →

telegram

npx machina-cli add skill shane9coy/Telegram-Bot-Easy/telegram --openclaw
Files (1)
SKILL.md
4.4 KB

Telegram 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):

CredentialHow to Get
TELEGRAM_BOT_TOKENMessage @BotFather on Telegram, use /newbot
TELEGRAM_BOT_USER_IDMessage @userinfobot on Telegram
TELEGRAM_API_IDGo to https://my.telegram.org → API Development Tools
TELEGRAM_API_HASHGo 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

WhatCommand
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:

TierMechanismCommands
DirectPure Python + API callstasks, goals, weather, status
QueueWrite to /tmp/telegram_agent_queue.jsoncomplex 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

  1. 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"
    
  2. Import in telegram_listener.py:

    from telegram_helpers import get_my_service
    
  3. 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

CommandAction
/tasksToday's tasks
add task: ...Add a task
done: ... / done 1Complete a task
/goalsActive goals
add goal: ...Add a goal
/progressToday's stats + streak

System

CommandAction
/helpFull command menu
/statusListener + system health
/weatherCurrent weather
sleep / goodnightEnter sleep mode
wake / good morningExit sleep mode

Scheduled Alerts

Configured in user_profile.jsontelegram:

TimeAlertConfig Key
8:00 AMMorning 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

  1. Step 1: Install dependencies with pip install -r requirements.txt.
  2. Step 2: Create and fill .env with TELEGRAM_BOT_TOKEN, TELEGRAM_BOT_USER_ID, TELEGRAM_API_ID, TELEGRAM_API_HASH.
  3. 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.

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers