| name | telegram |
| description | Read, search, and send Telegram messages via a Telethon-based CLI. Use when the user asks about Telegram messages, chats, contacts, groups, channels, or wants to send/search/read Telegram content. |
Telegram
Setup
Requires a one-time interactive login. The user must run this in their terminal:
/Users/adam/.pi/agent/skills/telegram/scripts/tg.sh login
This prompts for:
- API credentials from https://my.telegram.org/apps (api_id + api_hash) — only on first run
- Phone number and verification code from Telegram
Credentials are stored in ~/.config/telegram-cli/credentials (mode 600). Session in ~/.config/telegram-cli/session.session.
CLI
All commands return JSON on stdout: { ok, data } on success, { ok, error } on failure.
TG="/Users/adam/.pi/agent/skills/telegram/scripts/tg.sh"
Identity
$TG me
$TG info @username
$TG info 123456789
Listing Chats
$TG chats list
$TG chats list --limit 10 --unread
$TG chats list --type user
$TG chats list --archived
Searching Chats
$TG chats search "query"
$TG chats search "query" --limit 10
Reading Messages
$TG msg list @username --limit 10
$TG msg list @username --since 1711234567
$TG msg list @username --from @sender
$TG msg list @username --query "keyword"
$TG msg get @username 12345
Paginate with --offset-id using nextOffset from the previous response.
Searching Messages
$TG msg search "keyword"
$TG msg search "keyword" --chat @username
$TG msg search "keyword" --since 1711234567
$TG msg search "keyword" --until 1711320967
$TG msg search "keyword" --full
Paginate with --offset-id via nextOffset. Text is truncated to 500 chars by default; use --full when content matters.
Sending Messages
$TG send @username "Hello!"
$TG send @username "<b>bold</b>" --html
$TG send @username "**bold**" --md
$TG send @username "quiet" --silent
$TG send @username "reply" --reply-to 12345
echo "long text" | $TG send @username --stdin
Media
$TG download @chat 12345
$TG download @chat 12345 --output ./pic.jpg
Entity Resolution
Chats/users can be referenced by: numeric ID, @username, phone number, or t.me/link.
Rules
- Confirm before sending — always show the user what will be sent and to whom before executing send actions.
- Reads don't need confirmation — listing chats, reading messages, and searching are safe to do freely.
- Use search first — when the user refers to a chat by name, use
chats search to find the correct entity before reading messages.
- Paginate for completeness — if the user wants all messages or comprehensive results, use
--offset-id with nextOffset.
- Prefer --since for recent messages — convert relative times ("last hour", "today") to unix timestamps using
date.
- Use --full for search — message text is truncated to 500 chars by default in search results.
Stack
- Telethon v1.42 — MIT license, 12k GitHub stars, pure Python, auditable source
- Python venv at
/Users/adam/.pi/agent/skills/telegram/.venv/
- No precompiled binaries, no telemetry, no third-party services