Very Popular
Go to Latest
function webhookCallback
import { webhookCallback } from "https://dotland.deno.dev/x/grammy@v1.12.0/convenience/webhook.ts";

Creates a callback function that you can pass to a web framework (such as express) if you want to run your bot via webhooks. Use it like this:

const app = express() // or whatever you're using
const bot = new Bot('<token>')

app.use(webhookCallback(bot, 'express'))

Confer the grammY documentation to read more about how to run your bot with webhooks.

Type Parameters

optional
C extends Context = Context

Parameters

bot: Bot<C>

The bot for which to create a callback

optional
adapter: SupportedFrameworks | FrameworkAdapter

An optional string identifying the framework (default: 'express')

optional
onTimeout: WebhookOptions["onTimeout"]

An optional strategy to handle timeouts (default: 'throw')

optional
timeoutMilliseconds: WebhookOptions["timeoutMilliseconds"]

An optional number of timeout milliseconds (default: 10_000)

optional
secretToken: WebhookOptions["secretToken"]

Returns

(...args: any[]) => any

Type Parameters

optional
C extends Context = Context

Parameters

bot: Bot<C>
optional
adapter: SupportedFrameworks | FrameworkAdapter
optional
webhookOptions: WebhookOptions

Returns

(...args: any[]) => any