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 🙏

© 2025 – Pkg Stats / Ryan Hefner

telegram-message-send

v1.2.1

Published

Send message using telegram bot and api.

Readme

Telegram Message Send

This library provides a simple class-based interface for sending messages and various media types to a Telegram bot.

Installation

With yarn

yarn add telegram-message-send

With NPM

npm install telegram-message-send

Getting Started

import { TelegramBot } from 'telegram-message-send';

const botKey = 'YOUR_BOT_KEY';
const chatId = 'YOUR_CHAT_ID';

const bot = new TelegramBot(botKey, chatId);

async function sendMessages() {
  await bot.sendMessage('Hello World');
  await bot.sendPhoto('https://avatars.githubusercontent.com/u/100691616?s=200&v=4', 'Custom Caption');
  await bot.sendAudio('https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3', 'Custom Caption');
  await bot.sendDocument('https://s2.q4cdn.com/175719177/files/doc_presentations/Placeholder-PDF.pdf', 'Custom Caption');
  await bot.sendLocation(41.084677113651814, 29.00455392606353);
  await bot.sendContact('Ilker Balcilar', '+905555555555');
  await bot.sendPoll('Which one would you prefer', ['Javascript', 'Typescript']);
  await bot.sendDice('dice'); // or 'dart', 'basketball', etc.
}


sendMessages();

Create a new Telegram bot with BotFather

Create a Telegram bot with BotFather before connecting your bot to Telegram.

  1. Start a new conversation with the BotFather.
  2. Send /newbot to create a new Telegram bot.
  3. When asked, enter a name for the bot.
  4. Copy and save the Telegram bot's access token (your botKey) for later steps.

Get Your Telegram Chat ID

  1. In your Telegram account, search for “@myidbot” or open this link t.me/myidbot on your smartphone.
  2. Start a conversation with that bot and type /getid. You will get a reply back with your user ID.
  3. Note the user ID (your chatId).

In order to receive a message from the bot, you must first send a message to the bot and create a chat.

TelegramBot Class Methods

new TelegramBot(botKey, chatId)

  • botKey (string, required): Your Telegram bot's access token.
  • chatId (string, required): The ID of the chat to send messages to.

sendMessage(text)

  • text (string, required): The message text to send.

sendPhoto(photoURL, caption?)

  • photoURL (string, required): URL of the photo to send.
  • caption (string, optional): Photo caption.

sendAudio(audioURL, caption?)

  • audioURL (string, required): URL of the audio file to send.
  • caption (string, optional): Audio caption.

sendDocument(documentURL, caption?)

  • documentURL (string, required): URL of the document to send.
  • caption (string, optional): Document caption.

sendVideo(videoURL, caption?)

  • videoURL (string, required): URL of the video to send.
  • caption (string, optional): Video caption.

sendGIF(gifURL, caption?)

  • gifURL (string, required): URL of the GIF to send.
  • caption (string, optional): GIF caption.

sendLocation(latitude, longitude)

  • latitude (number, required): Latitude of the location.
  • longitude (number, required): Longitude of the location.

sendContact(name, phoneNumber)

  • name (string, required): Contact's name.
  • phoneNumber (string, required): Contact's phone number.

sendPoll(question, options)

  • question (string, required): Poll question.
  • options (string[], required): Array of poll options.

sendDice(type?)

  • type (string, optional): Type of dice to send ('dice', 'dart', 'basketball', 'football', 'bowling', 'slot'). Defaults to 'dice'.