npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

telegram-send-message-cli

v0.2.1

Published

Tiny CLI + TypeScript helper to send messages to Telegram chats via bot token and chat id.

Readme

telegram-send-message-cli

Typed Node.js utility that exposes a sendMessage command-line tool and programmatic helper for sending Telegram notifications from scripts, CI jobs, or local workflows.

Installation

npm install -g telegram-send-message-cli

You can also add it to a project:

npm install --save-dev telegram-send-message-cli

The package ships pre-built JavaScript and TypeScript declaration files for Node.js 18 and newer.

Configuration

The CLI needs a Telegram bot token and target chat identifier. Provide them through environment variables or CLI flags.

export TELEGRAM_BOT_TOKEN="your_bot_token"
export TELEGRAM_CHAT_ID="123456789"

These variables are read by default. They can also be passed explicitly:

sendMessage "Task done" --token "$TELEGRAM_BOT_TOKEN" --chat-id "$TELEGRAM_CHAT_ID"

Optional flags:

  • --parse-mode <MODE> – pass MarkdownV2, HTML, etc.
  • --disable-notification – send a silent notification.
  • --credentials-url <URL> – download TELEGRAM_BOT_TOKEN/TELEGRAM_CHAT_ID from a remote shell file.
  • -v|--version – show package version.
  • -h|--help – show usage information.

Usage

Send a message directly:

sendMessage "Build completed"

Pipe from another command:

cat build.log | sendMessage --parse-mode MarkdownV2

Loading credentials from a Gist

If you store your Telegram credentials in a private GitHub Gist (or any HTTPS-accessible shell snippet), point the CLI to it:

export TELEGRAM_CREDENTIALS_URL="https://gist.githubusercontent.com/.../telegram_credentials.sh"
sendMessage "Deploy finished"

The file should contain assignments such as:

TELEGRAM_BOT_TOKEN=123:abc
TELEGRAM_CHAT_ID=456

You can also pass the URL explicitly with --credentials-url.

Programmatic API

The module exports an async sendMessage helper. Example:

import { sendMessage } from 'telegram-send-message-cli';

await sendMessage({
  token: process.env.TELEGRAM_BOT_TOKEN!,
  chatId: process.env.TELEGRAM_CHAT_ID!,
  text: 'Task finished ✅',
  parseMode: 'MarkdownV2',
});

The helper throws SendMessageError when the request fails or Telegram returns ok: false.

Development

Clone the repository and install dependencies:

npm install

Available scripts:

  • npm run lint – TypeScript type-checking
  • npm test – runs Vitest unit tests
  • npm run build – emits compiled files to dist/

Publishing is automated through the Publish Package GitHub workflow. Pushing to main with a new version in package.json will run lint, tests, build, and publish to npm when the version is not already released.

The workflow sends a Telegram notification on completion, sourcing credentials via the same TELEGRAM_CREDENTIALS_URL mechanism. Update the gist referenced in .github/workflows/publish.yml to rotate secrets without modifying the repository.

Troubleshooting

  • Ensure the bot token has access to the specified chat. For private chats you might need to initiate a conversation with the bot first.
  • Telegram limits the rate of messages; watch for retry_after hints in error responses printed by the CLI.
  • Add TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID to your shell startup files so they are available in every session.

License

MIT