Skip to content
This repository has been archived by the owner on Feb 10, 2023. It is now read-only.

realByg/cfworker-telegrambot-template

Repository files navigation

🤖 cfworker-telegrambot-template

Host your Telegram bot on Cloudflare workers

🏃‍♀️ Setup

  1. Install wrangler and login with your Cloudflare account.
    $ npm i @cloudflare/wrangler -g
    
  2. Install ngrok for local port forwarding.

🎴 Getting started

  1. Generate your project and install the dependencies.
    $ wrangler generate my-project /~https://github.com/zayabighead/cfworker-telegrambot-template --type=webpack
    $ npm i
    
  2. Rename bot.config.example.js to bot.config.js and setup your bot configuration.
    // bot.config.js
    module.exports = {
        token: '', //get your bot token from @botfather
        webhookPath: '/wefwefwefe', // a random string
    }
    
  3. Rename wrangler.example.toml to wrangler.toml and setup your wrangler configuration.

👉 Development

The main idea is to set up a local dev port and use ngrok to forward the port after setting the ngrok temporary url as the bot's webhook.

  1. Run npm run ngrok to start ngrok local port forwrading.
  2. Run npm run webhook to set the webhook for the bot.
  3. Run npm run dev to start wrangler dev.

📢 Deployment

  1. Run npm run webhook to set the webhook for the bot.
  2. Run npm run publish to publish to a Cloudflare worker.

🤨 Limitations

📘 Useful docs

About

Host your Telegram bot on Cloudflare workers

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published