Skills node-telegram-cli
CLI tool for Telegram via MTProto. Send/read messages, manage groups, search conversations, download media, and automate Telegram workflows. Use when the task involves any Telegram account interaction.
install
source · Clone the upstream repo
git clone https://github.com/openclaw/skills
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/openclaw/skills "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/baontq23/telegram-cli" ~/.claude/skills/clawdbot-skills-node-telegram-cli && rm -rf "$T"
manifest:
skills/baontq23/telegram-cli/SKILL.mdsource content
Source & Trust
- Repository: https://github.com/baontq23/node-telegram-cli
- npm: https://www.npmjs.com/package/node-telegram-cli (published with provenance)
- Credentials are stored securely via OS Keychain (macOS Keychain / Windows Credential Manager / Linux Secret Service), not in plaintext files
Installation
- Requires Node.js >= 20
- Install globally:
npm install -g node-telegram-cli - Verify:
ntg --version - Run
once — interactive, requires phone number + OTP code from Telegramntg login
Critical Rule: Always Use JSON Mode
- Add
flag to every command for machine-readable output--json
is a global flag — place it before or after the subcommand--json- Example:
,ntg --json inboxntg --json search @user "keyword"
Peer Format
— most reliable, e.g.@username@johndoe- Phone number — for contacts without username, e.g.
+84901234567
— your own Saved Messagesme- Chat title — group/channel name in quotes, e.g.
"My Group"
Read Commands (No Side Effects)
— list recent conversationsntg --json inbox
— only unread conversationsntg --json inbox --unread
— only private 1-on-1 chatsntg --json inbox --private
— combine filtersntg --json inbox --unread --private
— messages from a specific chatntg --json inbox --chat <peer> --limit <n>
— search in a specific chatntg --json search <peer> "keyword"
— search across all chatsntg --json global-search "keyword"
— show group/channel infontg --json chat-info <chat>
Write Commands (Has Side Effects)
— send a text messagentg msg <peer> "text"
— send silently (no notification sound)ntg msg <peer> "text" --silent
— forward a message by IDntg fwd <user> <msgId>
— mark all messages as readntg mark-read <peer>
— delete a messagentg delete-msg <msgId>
— send a photontg send-photo <peer> <file>
— send a videontg send-video <peer> <file>
— send a text file as plain messagesntg send-file <peer> <file>
— download media from a messagentg download <msgId> --chat <peer>
— specify media type (photo, video, audio, doc)ntg download <msgId> --chat <peer> --type <type>
— download and open with system viewerntg view <msgId> --chat <peer>
— delete all downloaded media filesntg clean-downloads
Group Management
— create a new groupntg create-group "Topic" @user1 @user2
— add a user to a groupntg chat-add <chat> <user>
— remove a user from a groupntg chat-kick <chat> <user>
— rename a groupntg chat-rename <chat> "New Name"
— set group photontg chat-set-photo <chat> <file>
Contact Management
— add a contactntg add-contact <phone> <firstName> <lastName>
— rename a contactntg rename-contact <user> <firstName> <lastName>
JSON Output Schemas
Inbox (conversation list)
— contact/chat display namename
— identifier to use aspeer
argument<peer>
— "username" | "phone" | "id"peerType
— "user" | "group" | "channel"type
— number of unread messagesunreadCount
— text/caption (empty string if media-only)lastMessage
— use withlastMessageId
for mediantg download <id>
— "photo" | "video" | "document" | "audio" | "voice" | "sticker" | "location" | "contact" | "poll" | nullmediaType
— ISO 8601 timestampdate
Chat messages (inbox --chat)
— message IDid
— ISO 8601 timestampdate
— sender display namesender
— message text/captiontext
— same values as abovemediaType
— true if sent by youisOutgoing
Error Handling
- Exit code
= success0 - Exit code
= error (not logged in, peer not found, etc.)1 - If not logged in, commands fail with: "Not logged in. Run ntg login first."
Important Notes
- Do NOT use
— it is interactive, blocks stdin, not suitable for automationntg chat <peer> - Session persists until
is called — no re-login needed between commandsntg logout - Downloaded files are saved to
~/.telegram-cli/downloads/ - Always specify
when downloading media to identify the source chat--chat <peer>