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

x/grammy/mod.ts>Api#setWebhook

The Telegram Bot Framework.
Very Popular
Latest
method Api.prototype.setWebhook
import { Api } from "https://deno.land/x/grammy@v1.30.1/mod.ts";

Use this method to specify a URL and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified URL, containing a JSON-serialized Update. In case of an unsuccessful request, we will give up after a reasonable amount of attempts. Returns True on success.

If you'd like to make sure that the webhook was set by you, you can specify secret data in the parameter secret_token. If specified, the request will contain a header “X-Telegram-Bot-Api-Secret-Token” with the secret token as content.

Notes

  1. You will not be able to receive updates using getUpdates for as long as an outgoing webhook is set up.
  2. To use a self-signed certificate, you need to upload your public key certificate using certificate parameter. Please upload as InputFile, sending a String will not work.
  3. Ports currently supported for Webhooks: 443, 80, 88, 8443.

If you're having any trouble setting up webhooks, please check out this amazing guide to webhooks.

Parameters

url: string

HTTPS url to send updates to. Use an empty string to remove webhook integration

optional
other: Other<R, "setWebhook", "url">

Optional remaining parameters, confer the official reference below

optional
signal: AbortSignal

Optional AbortSignal to cancel the request

Official reference: https://core.telegram.org/bots/api#setwebhook