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

x/grammy/mod.ts>webhookCallback

The Telegram Bot Framework.
Very Popular
Latest
function webhookCallback
import { webhookCallback } from "https://deno.land/x/grammy@v1.30.1/mod.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
optional
A extends FrameworkAdapter | AdapterNames = FrameworkAdapter | AdapterNames

Parameters

bot: Bot<C>

The bot for which to create a callback

adapter: A

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

optional
webhookOptions: WebhookOptions

Further options for the webhook setup

Returns

(...args: Parameters<ResolveName<A>>) => ReturnType<ResolveName<A>>["handlerReturn"] extends undefined ? Promise<void> : NonNullable<ReturnType<ResolveName<A>>["handlerReturn"]>

Type Parameters

optional
C extends Context = Context
optional
A extends FrameworkAdapter | AdapterNames = FrameworkAdapter | AdapterNames

Parameters

bot: Bot<C>
adapter: A
optional
onTimeout: WebhookOptions["onTimeout"]
optional
timeoutMilliseconds: WebhookOptions["timeoutMilliseconds"]
optional
secretToken: WebhookOptions["secretToken"]

Returns

(...args: Parameters<ResolveName<A>>) => ReturnType<ResolveName<A>>["handlerReturn"] extends undefined ? Promise<void> : NonNullable<ReturnType<ResolveName<A>>["handlerReturn"]>