Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/grammy/mod.ts>Bot#start

The Telegram Bot Framework.
Very Popular
Latest
method Bot.prototype.start
Re-export
import { Bot } from "https://deno.land/x/grammy@v1.32.0/mod.ts";

Starts your bot using long polling.

This method returns a Promise that will never resolve except if your bot is stopped. You don't need to await the call to bot.start, but remember to catch potential errors by calling bot.catch. Otherwise your bot will crash (and stop) if something goes wrong in your code.

This method effectively enters a loop that will repeatedly call getUpdates and run your middleware for every received update, allowing your bot to respond to messages.

If your bot is already running, this method does nothing.

Note that this starts your bot using a very simple long polling implementation. bot.start should only be used for small bots. While the rest of grammY was built to perform well even under extreme loads, simple long polling is not capable of scaling up in a similar fashion. You should switch over to using @grammyjs/runner if you are running a bot with high load.

What exactly high load means differs from bot to bot, but as a rule of thumb, simple long polling should not be processing more than ~5K messages every hour. Also, if your bot has long-running operations such as large file transfers that block the middleware from completing, this will impact the responsiveness negatively, so it makes sense to use the @grammyjs/runner package even if you receive much fewer messages. If you worry about how much load your bot can handle, check out the grammY documentation about scaling up.

Parameters

optional
options: PollingOptions

Options to use for simple long polling