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

@codebam/cf-workers-telegram-bot

v12.6.20

Published

serverless telegram bot on cf workers

Downloads

7,529

Readme

screenshot of cf-workers-telegram-bot

A lightweight, type-safe Telegram Bot framework for Cloudflare Workers.

Installation

npm install @codebam/cf-workers-telegram-bot

Quick Start

import TelegramBot, { TelegramExecutionContext } from '@codebam/cf-workers-telegram-bot';

export interface Env {
	SECRET_TELEGRAM_API_TOKEN: string;
}

export default {
	async fetch(request: Request, env: Env): Promise<Response> {
		const bot = new TelegramBot(env.SECRET_TELEGRAM_API_TOKEN);

		await bot
			.command('start', async (ctx) => {
				await ctx.reply('Hello! I am running on Cloudflare Workers.');
			})
			.onMessage(async (ctx) => {
				await ctx.reply(`You said: ${ctx.text}`);
			})
			.handle(request);

		return new Response('ok');
	},
};

Features

  • Type-safe: Built with TypeScript for a better developer experience.
  • Middleware support: Run logic before your handlers.
  • Built-in Webhook Management: Easily set your webhook with a simple URL.
  • Lightweight: Zero dependencies (other than type definitions).

Using the Consumer Template

The consumer directory in this repository serves as a template for new projects. It is included as a git submodule.

  1. Clone the repository with submodules:

    git clone --recursive https://github.com/codebam/cf-workers-telegram-bot.git

    Or, if you've already cloned it:

    git submodule update --init --recursive
  2. Copy the consumer directory:

    cp -r consumer my-new-bot
    cd my-new-bot
    npm install
  3. Configure your bot: Update wrangler.toml with your worker name.

  4. Set your Telegram Token: Get a token from @BotFather and add it to your worker:

    npx wrangler secret put SECRET_TELEGRAM_API_TOKEN
  5. Deploy:

    npm run deploy
  6. Set Webhook: Visit the following URL in your browser to register your worker with Telegram: https://<your-worker>.<your-subdomain>.workers.dev/<SECRET_TELEGRAM_API_TOKEN>/setWebhook

Deployment

Manual Deployment

Use Wrangler to deploy:

npx wrangler deploy

GitHub Actions

To automate deployments, use the Wrangler Action or Cloudflare's built-in GitHub integration.

Structure

This is a monorepo containing:

  • Root: Core library @codebam/cf-workers-telegram-bot
  • ai-workflow: A Cloudflare Workflow for handling long-running AI tasks
  • webapp: A Svelte 5 web application for interacting with the bot
  • consumer: A minimal consumer of the library

Development

You can use the root Makefile to run common tasks across all projects:

make build   # Build all projects
make test    # Run tests for all projects
make lint    # Lint all projects
make format  # Format all projects

Setup

  1. Install dependencies:

    npm install
  2. Set up Git hooks: This project uses custom Git hooks for quality control. Run the following script to enable them:

    ./setup_hooks.sh

Scripts

  • npm run lint: Run ESLint on the source code.
  • npm run format: Format the code using Prettier.
  • npm run build: Compile TypeScript and run type checks.
  • npm run test: Run unit tests with Vitest.
  • npm run lint:all: Run linting for the root project and all subprojects.
  • npm run build:all: Run build for the root project and all subprojects.
  • npm run test:all: Run tests for the root project and all subprojects.

The pre-commit hook automatically runs formatting and linting on staged files (via lint-staged), followed by a full project type check and tests before every commit.

API Documentation

Detailed API documentation is available at cf-workers-telegram-bot.codebam.ca.

License

Apache-2.0