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-ai-bot

v1.0.1

Published

AI-powered Telegram bot template — customizable for any niche. Claude API, Stripe payments, multi-language, Cloudflare Workers ready.

Readme

AI Bot Starter Kit for Telegram

A production-ready Telegram bot template powered by Claude AI, with Stripe payments, multi-language support, and one-click deployment to Cloudflare Workers.

Customize it for any niche: fitness coach, language tutor, business assistant, or anything else.

Features

  • Claude AI responses with conversation memory (last 10 messages)
  • Free/Premium tiers with rate limiting (20 msgs/day free, unlimited premium)
  • Stripe integration for $9.99/month premium subscriptions
  • Multi-language support (English & French, easily extensible)
  • Serverless deployment on Cloudflare Workers (free tier eligible)
  • Commands: /start, /help, /reset, /lang, /premium, /stats
  • Analytics endpoint for tracking users and messages
  • Niche templates: general, fitness, language, business (just change one env var)

Quick Start

Prerequisites

1. Install

npm install

2. Configure Secrets

# Copy the example env file for local dev
cp .dev.vars.example .dev.vars
# Edit .dev.vars with your keys

# For production, set secrets via Wrangler:
wrangler secret put TELEGRAM_BOT_TOKEN
wrangler secret put TELEGRAM_WEBHOOK_SECRET
wrangler secret put ANTHROPIC_API_KEY
wrangler secret put STRIPE_SECRET_KEY
wrangler secret put STRIPE_WEBHOOK_SECRET

3. Customize Your Bot

Edit wrangler.toml:

[vars]
BOT_NAME = "FitCoach AI"          # Your bot's display name
BOT_NICHE = "fitness"              # general | fitness | language | business
DEFAULT_LANGUAGE = "en"            # en | fr
FREE_DAILY_LIMIT = "20"           # Free tier message limit
STRIPE_PAYMENT_LINK = "https://buy.stripe.com/your-link"

4. Deploy

# Local development
npm run dev

# Deploy to Cloudflare Workers
npm run deploy

5. Set Up Webhook

After deploying, register your webhook with Telegram:

https://your-worker.your-subdomain.workers.dev/setup?url=https://your-worker.your-subdomain.workers.dev

6. Set Up Stripe (Premium)

  1. Create a Product in Stripe Dashboard ($9.99/month recurring)
  2. Create a Payment Link for that product
  3. Add ?client_reference_id={CHECKOUT_SESSION_ID} to the link
  4. Set up a Stripe Webhook pointing to https://your-worker.dev/stripe
  5. Subscribe to checkout.session.completed and customer.subscription.deleted
  6. Add metadata field telegram_user_id to your checkout session

API Endpoints

| Endpoint | Method | Purpose | |---|---|---| | / | GET | Health check | | /webhook?secret=... | POST | Telegram webhook receiver | | /stripe | POST | Stripe webhook receiver | | /setup?url=... | GET | Register Telegram webhook | | /analytics | GET | User and message statistics |

Customization

Add a New Niche

Edit src/types.ts and add your niche to NICHE_PROMPTS:

export const NICHE_PROMPTS = {
  // ...existing niches...
  cooking: "You are a professional chef and cooking instructor on Telegram...",
};

Then set BOT_NICHE = "cooking" in wrangler.toml.

Add a New Language

Edit src/i18n.ts and add translations for each string key:

welcome: {
  en: "Welcome...",
  fr: "Bienvenue...",
  es: "Bienvenido...",  // Add Spanish
},

Use Persistent Storage

Replace InMemoryStore in src/bot.ts with your own implementation of the UserStore interface. Works with:

  • Cloudflare KV (key-value, eventually consistent)
  • Cloudflare D1 (SQLite, transactional)
  • Redis (via Upstash for serverless)

Architecture

Telegram --> Cloudflare Worker --> Claude API
                |
                +--> Stripe (payments)
                +--> In-memory store (users, conversations)

Cost Estimate

| Component | Free Tier | Paid | |---|---|---| | Cloudflare Workers | 100k req/day | $5/month unlimited | | Claude API (Sonnet) | - | ~$0.003/message | | Stripe | - | 2.9% + $0.30 per transaction | | Telegram | Free | Free |

Break-even: ~4 premium subscribers cover the API costs for ~1000 messages/day.

License

MIT License. See LICENSE for details.

Legal