how can I add Menu button in telegram bot using telegraf
how can I add menu button in telegram bot
Asked Answered
Stack Overflow is a Q&A site; however it doesn’t seem you’ve asked a question. How to Ask –
Targum
I create a menu button by add a new framework " Grammy "
first install grammy : npm install grammy
seconde add this code :
const { Bot } = require("grammy");
const bot = new Bot(BOT_TOKEN); // <-- place your bot token in this string
create list of commands :
bot.api.setMyCommands([
{ command: "start", description: "إبدأ من جديد" },
{ command: "help", description: "طلب مساعدة " },
{ command: "list", description: "القائمة " },
]);
You can achieve this in two ways. Either by
- using the
setMyCommands
method, or - contacting @BotFather to use its
/setcommands
command.
Be sure to restart the telegram app to see the menu appear –
Rania
I create a menu button by add a new framework " Grammy "
first install grammy : npm install grammy
seconde add this code :
const { Bot } = require("grammy");
const bot = new Bot(BOT_TOKEN); // <-- place your bot token in this string
create list of commands :
bot.api.setMyCommands([
{ command: "start", description: "إبدأ من جديد" },
{ command: "help", description: "طلب مساعدة " },
{ command: "list", description: "القائمة " },
]);
For simplicity, you can use BotFather and set it directly from there.
- Open BotFather - https://t.me/BotFather
- send him the command
/setcommands
thanks, but we need how to coding this option –
Holmic
If you're here to open your mini-app from that button, /setcommands is the wrong way to achieve that.
Here is how you can launch apps from telegram both
/mybots
select your bot
Bot Settings
Menu Button
Then add your url and tittle of your button
© 2022 - 2024 — McMap. All rights reserved.