When chatting with BotFather, you might notice a menu button at the bottom-left corner with various commands. How is this achieved? Keep reading to find out.
Redirect to a URL
For example, if you’ve created a webpage and want the bottom-left menu button to open this webpage directly, it’s quite simple. Here’s the code:
1 | import { Bot, api } from "https://deno.land/x/grammy@v1.25.0/mod.ts"; |
Run the code above, and when you open your bot interface, you’ll see that the menu button has changed to Open WebApp
. On a mobile device, you’ll notice a window icon next to the button, indicating that it’s correctly set up.
Setting Commands in the Menu
If you want to set up multiple commands in the menu like BotFather does, you can add various features to your bot. Here’s how:
1 | import { Bot, api } from "https://deno.land/x/grammy@v1.25.0/mod.ts"; |
Run the code above, and when you open your bot, you’ll see the menu you configured at the bottom left, as shown below:
Note: Neither of the methods above may take effect immediately due to potential caching.