Skip to content

Files

src

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Feb 27, 2025
Mar 20, 2025
Dec 30, 2023
Oct 27, 2024
Jul 18, 2024
Mar 20, 2025
Mar 5, 2025
Mar 23, 2025
Oct 22, 2023
Oct 22, 2023
Oct 8, 2023
Jan 20, 2022
Feb 12, 2025
Jul 18, 2024
Jul 31, 2022
Feb 12, 2025

grammY

The grammY module lets you easily write Telegram bots. Here is a quickstart for you to get started, but note that a better explanation is in our repo on GitHub.

You may also want to check out the docs.

Quickstart

Talk to @BotFather to create a new Telegram bot and obtain a bot token.

Paste the following code into a new file bot.ts.

import { Bot } from "https://deno.land/x/grammy/mod.ts";

// Create bot object
const bot = new Bot(""); // <-- place your bot token inside this string

// Listen for messages
bot.command("start", (ctx) => ctx.reply("Welcome! Send me a photo!"));
bot.on("message:text", (ctx) => ctx.reply("That is text and not a photo!"));
bot.on("message:photo", (ctx) => ctx.reply("Nice photo! Is that you?"));
bot.on(
    "edited_message",
    (ctx) =>
        ctx.reply("Ha! Gotcha! You just edited this!", {
            reply_parameters: { message_id: ctx.editedMessage.message_id },
        }),
);

// Launch!
bot.start();

Congratulations! You have successfully created your first Telegram bot.

You can run it like so:

deno run --allow-net bot.ts