| name | telegram-cli |
| description | Interact with Telegram directly from Claude Code - send/read messages, manage chats, search conversations, download media, manage contacts, and automate Telegram workflows. Use when the user needs to send a Telegram message, read chat history, search messages, manage groups/channels, download or upload media, work with contacts, or perform any Telegram operation. |
| allowed-tools | Bash(tg:*) |
Telegram CLI - Agent-First Telegram Client
Prerequisites
The tg command must be available. Install globally:
npm install -g @miolamio/tg-cli
You must be authenticated before using any command (except tg auth login):
tg auth status
If not logged in, the user must authenticate interactively (requires TTY):
tg auth login
Quick start
tg auth status
tg chat list --limit 10
tg message history @username --limit 20
tg message send @username "Hello from Claude Code!"
tg message search --query "meeting notes"
tg media download @channel 42
Output modes
All commands support 4 output modes. Default is JSON.
tg chat list
tg chat list --human
tg chat list --jsonl
tg chat list --toon
tg chat list --fields "id,title"
For agent workflows: prefer --toon for large outputs (saves tokens) or --jsonl for streaming list data. Use --fields to narrow output to only what you need.
Mutually exclusive: --toon / --human / --jsonl (pick one).
Global options
Available on every command:
--json
--human
--jsonl
--toon
--fields <fields>
-v, --verbose
-q, --quiet
--profile <name>
--config <path>
Commands
Auth
tg auth login
tg auth status
tg auth logout
Session
tg session export
tg session import <session>
tg session import --skip-verify
Chat
tg chat list
tg chat list --type user
tg chat list --limit 20 --offset 5
tg chat info <chat>
tg chat join <target>
tg chat leave <chat>
tg chat resolve <input>
tg chat invite-info <link>
tg chat members <chat>
tg chat members <chat> --search "John"
tg chat members <chat> --limit 50 --offset 0
tg chat topics <chat>
Message - Reading
tg message history <chat>
tg message history <chat> --limit 100
tg message history <chat> --since 2026-03-01T00:00:00Z
tg message history <chat> --until 2026-03-13T23:59:59Z
tg message history <chat> --topic <id>
tg message get <chat> <ids>
tg message pinned <chat>
tg message pinned <chat> --limit 10 --offset 0
tg message replies <channel> <ids>
tg message replies <channel> <ids> --limit 50
Message - Searching
tg message search --query "keyword"
tg message search --query "keyword" --chat @username
tg message search --chat @channel --filter photos
tg message search --chat @group --topic <id>
tg message search --limit 20 --offset 0
Search filters (17 types):
photos, videos, photo_video, documents, urls, gifs, voice, music, round, round_voice, chat_photos, phone_calls, mentions, geo, contacts, pinned
Message - Sending & Interaction
tg message send <chat> "Hello!"
tg message send <chat> "Reply" --reply-to 42
tg message send <chat> "Topic msg" --topic <id>
echo "piped text" | tg message send <chat> -
tg message edit <chat> <id> "Updated text"
echo "new text" | tg message edit <chat> <id> -
tg message forward <from> <ids> <to>
tg message react <chat> <id> <emoji>
tg message react <chat> <id> <emoji> --remove
tg message delete <chat> <ids> --revoke
tg message delete <chat> <ids> --for-me
tg message pin <chat> <id>
tg message pin <chat> <id> --notify
tg message unpin <chat> <id>
Message - Polls
tg message poll <chat> --question "Lunch?" --option "Pizza" --option "Sushi" --option "Tacos"
tg message poll <chat> --question "Capital of France?" --option "London" --option "Paris" --option "Berlin" --quiz --correct 1 --solution "Paris is the capital"
tg message poll <chat> --question "Pick all" --option "A" --option "B" --option "C" --multiple
tg message poll <chat> --question "Vote" --option "Yes" --option "No" --public
tg message poll <chat> --question "Quick?" --option "A" --option "B" --close-in 3600
Media
tg media download <chat> <ids>
tg media download <chat> <ids> -o ./photo.jpg
tg media send <chat> ./photo.jpg
tg media send <chat> ./a.jpg ./b.jpg
tg media send <chat> ./doc.pdf --caption "Report"
tg media send <chat> ./img.png --reply-to 42
tg media send <chat> ./img.png --topic <id>
User
tg user profile <users>
tg user block <user>
tg user unblock <user>
tg user blocked
tg user blocked --limit 20 --offset 0
Contact
tg contact list
tg contact list --limit 50 --offset 0
tg contact add @username
tg contact add +1234567890 --first-name "John" --last-name "Doe"
tg contact delete <user>
tg contact search "query"
tg contact search "query" --global
tg contact search "query" --limit 10
Chat identifiers
Most commands accept <chat> which can be:
- Username:
durov or @durov
- Numeric ID:
123456789 or -100123456789
- Phone number:
+1234567890
Examples
Monitor a channel for new messages
tg message history @channel --limit 5 --toon
Search and read a conversation thread
tg message search --query "project update" --chat @team_group --limit 10
tg message replies @team_group 1234 --limit 20
Send a file with context
tg media send @colleague ./report.pdf --caption "Q1 Report - see page 3 for highlights"
Get overview of a group
tg chat info @group_name
tg chat members @group_name --limit 10
tg message pinned @group_name
tg message history @group_name --limit 10 --toon
Forward messages between chats
tg message forward @source_chat 100,101,102 @destination_chat
Create a poll
tg message poll @team_chat --question "Sprint retrospective: what went well?" --option "CI/CD improvements" --option "Code review process" --option "Documentation" --option "Testing coverage" --multiple --public
Export session for use in another environment
tg session export
tg session import "exported_session_string_here"
Narrow output with --fields
tg chat list --fields "id,title,type" --limit 5
tg message history @chat --fields "id,text,date,senderId" --limit 10
tg user profile @username --fields "id,username,firstName,bio"
Specific tasks