SuperAPI AI Directory

telegram-send

Office & productivity

View repository

Updated 10-22 16:15

About this skill

telegram-send

Send messages to Telegram groups and channels that the agent's Telegram bot can access.

Overview

This skill lets the user instruct the agent to broadcast a message to any Telegram group or channel the bot has previously interacted with.

Required Environment Variables

  • TELEGRAM_BOT_TOKEN — Telegram bot token. Auto-discovered from channels.telegram.token in ~/.nanobot/config.json (override path with NANOBOT_CONFIG) if not set in the environment.

$SKILL_DIR in the commands below means this skill's installed directory. If your agent does not set it automatically, replace it with the path to this telegram-send directory before running the command.

Optional (YouAI runtime)

  • YOUAI_API_URL — YouAI backend URL (fallback group discovery when no local sessions exist)
  • YOUAI_TWIN_ID — Twin ID (required together with YOUAI_API_URL)

Commands

List known groups

python3 "$SKILL_DIR/scripts/list_groups.py"

Returns a JSON array of group chats the bot has interacted with:

[
  {"chat_id": -1001234567890, "name": "Team Chat", "type": "supergroup"},
  {"chat_id": -987654321, "name": "Marketing", "type": "group"}
]

Returns [] if no groups are known yet or the backend is unreachable.

Send a message to a specific chat

python3 "$SKILL_DIR/scripts/send.py" <chat_id> "<message>"

Example:

python3 "$SKILL_DIR/scripts/send.py" -1001234567890 "Meeting at 3pm today!"

Prints one JSON result on stdout and exits 0 on success, 1 on failure (diagnostics go to stderr).

Send to all groups matching a keyword

python3 "$SKILL_DIR/scripts/send.py" --keyword <substr> "<message>"

Fetches all known groups, filters by name (case-insensitive substring match), and sends to every match.

Example:

python3 "$SKILL_DIR/scripts/send.py" --keyword crypto "Market update: BTC up 5%!"

Prints one JSON result containing per-group success/error records. Exits 0 if all sends succeeded, 1 if any failed.

Usage Instructions

  1. When the user asks to send a message to a specific group, first run list_groups.py to discover available groups and resolve the target group name to a chat_id.
  2. If the requested group is not in the list, inform the user that the bot has not received any messages from that group yet (the bot must be added and have received at least one message for it to appear).
  3. Run send.py with the resolved chat_id and the message text.
  4. Never guess or fabricate a chat_id.
  5. When the user asks to send to multiple groups matching a keyword (e.g. "send to all crypto groups"), use send.py --keyword <substr> "<message>" — it handles the lookup and fan-out internally.

Notes

  • Only groups that have sent at least one message to this bot/agent are discoverable.
  • name is resolved via the Telegram Bot API (getChat) using TELEGRAM_BOT_TOKEN. If the bot has been removed from a group, name will be null — the chat_id is still valid for sending if the bot is re-added.
  • The bot must still be a member of the group for the send to succeed.
  • Messages support standard Markdown formatting: **bold**, *italic*, _italic_, `code`, ```code blocks```, ~~strikethrough~~. Code spans are preserved literally while prose is converted to Telegram HTML.

Related Skills