Setup & Installation

clawhub install telegram-cli

Or with OpenClaw CLI:

openclaw skills install telegram-cli

What This Skill Does

Telegram cli is a Productivity & Workflow skill that 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..

Source & Trust

  1. Repository: https://github.com/baontq23/node-telegram-cli
  2. npm: https://www.npmjs.com/package/node-telegram-cli (published with provenance)
  3. Credentials are stored securely via OS Keychain (macOS Keychain / Windows Credential Manager / Linux Secret Service), not in plaintext files

Installation

  1. Requires Node.js >= 20
  2. Install globally: npm install -g node-telegram-cli
  3. Verify: ntg --version
  4. Run ntg login once โ€” interactive, requires phone number + OTP code from Telegram

Critical Rule: Always Use JSON Mode

  1. Add --json flag to every command for machine-readable output
  2. --json is a global flag โ€” place it before or after the subcommand
  3. Example: ntg --json inbox, ntg --json search @user "keyword"

Peer Format

  1. @username โ€” most reliable, e.g. @johndoe
  2. Phone number โ€” for contacts without username, e.g. +84901234567
  3. me โ€” your own Saved Messages
  4. Chat title โ€” group/channel name in quotes, e.g. "My Group"

Read Commands (No Side Effects)

  1. ntg --json inbox โ€” list recent conversations
  2. ntg --json inbox --unread โ€” only unread conversations
  3. ntg --json inbox --private โ€” only private 1-on-1 chats
  4. ntg --json inbox --unread --private โ€” combine filters
  5. ntg --json inbox --chat <peer> --limit <n> โ€” messages from a specific chat
  6. ntg --json search <peer> "keyword" โ€” search in a specific chat
  7. ntg --json global-search "keyword" โ€” search across all chats
  8. ntg --json chat-info <chat> โ€” show group/channel info

Write Commands (Has Side Effects)

  1. ntg msg <peer> "text" โ€” send a text message
  2. ntg msg <peer> "text" --silent โ€” send silently (no notification sound)
  3. ntg fwd <user> <msgId> โ€” forward a message by ID
  4. ntg mark-read <peer> โ€” mark all messages as read
  5. ntg delete-msg <msgId> โ€” delete a message
  6. ntg send-photo <peer> <file> โ€” send a photo
  7. ntg send-video <peer> <file> โ€” send a video
  8. ntg send-file <peer> <file> โ€” send a text file as plain messages
  9. ntg download <msgId> --chat <peer> โ€” download media from a message
  10. ntg download <msgId> --chat <peer> --type <type> โ€” specify media type (photo, video, audio, doc)
  11. ntg view <msgId> --chat <peer> โ€” download and open with system viewer
  12. ntg clean-downloads โ€” delete all downloaded media files

Group Management

  1. ntg create-group "Topic" @user1 @user2 โ€” create a new group
  2. ntg chat-add <chat> <user> โ€” add a user to a group
  3. ntg chat-kick <chat> <user> โ€” remove a user from a group
  4. ntg chat-rename <chat> "New Name" โ€” rename a group
  5. ntg chat-set-photo <chat> <file> โ€” set group photo

Contact Management

  1. ntg add-contact <phone> <firstName> <lastName> โ€” add a contact
  2. ntg rename-contact <user> <firstName> <lastName> โ€” rename a contact

JSON Output Schemas

Inbox (conversation list)

  1. name โ€” contact/chat display name
  2. peer โ€” identifier to use as <peer> argument
  3. peerType โ€” "username" | "phone" | "id"
  4. type โ€” "user" | "group" | "channel"
  5. unreadCount โ€” number of unread messages
  6. lastMessage โ€” text/caption (empty string if media-only)
  7. lastMessageId โ€” use with ntg download <id> for media
  8. mediaType โ€” "photo" | "video" | "document" | "audio" | "voice" | "sticker" | "location" | "contact" | "poll" | null
  9. date โ€” ISO 8601 timestamp

Chat messages (inbox --chat)

  1. id โ€” message ID
  2. date โ€” ISO 8601 timestamp
  3. sender โ€” sender display name
  4. text โ€” message text/caption
  5. mediaType โ€” same values as above
  6. isOutgoing โ€” true if sent by you

Error Handling

  1. Exit code 0 = success
  2. Exit code 1 = error (not logged in, peer not found, etc.)
  3. If not logged in, commands fail with: "Not logged in. Run ntg login first."

Important Notes

  1. Do NOT use ntg chat <peer> โ€” it is interactive, blocks stdin, not suitable for automation
  2. Session persists until ntg logout is called โ€” no re-login needed between commands
  3. Downloaded files are saved to ~/.telegram-cli/downloads/
  4. Always specify --chat <peer> when downloading media to identify the source chat

Version History

Latest version: 1.0.5

First published: Mar 23, 2026. Last updated: Mar 23, 2026.

1 version released.

Frequently Asked Questions

Is Telegram cli free to use?
Yes. Telegram cli is a free, open-source skill available on the OpenClaw Skills Registry.
What platforms does Telegram cli support?
It runs on any platform that supports OpenClaw, including macOS, Linux, and Windows.