Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show options in telegram bot?

Tags:

telegram-bot

I want to write a bot telegram.How to put possible option in my bot.I insert a picture of sample bot with this functionality.

enter image description here

like image 359
maryam Avatar asked Dec 24 '15 20:12

maryam


People also ask

How can I customize my telegram bot?

To customize your profile (defined on Telegram as "bot"), you need to send a message to BotFather (you can use this link: https://t.me/botfather), texting /mybots. From the chat select then the bot you connected to Callbell. Once the bot is selected, click on Edit Bot.


2 Answers

For that, you have to talk to BotFather.

  1. In the Telegram App, open the chat with BotFather.

  2. Send him /setcommands. He will present you with a list of your bots.

  3. Pick the bot for which you want to set the command menu.

  4. Compose and send the command list. Using your image as an example, these 4 lines should do:

start - Description 1
menu - Description 2
help - Description 3
stop - Description 4

Note that command part of each line(left side of - signs) must have just lowercase characters, and no slashes. There should also be spaces around the - sign.

Once you complete this process, exit and kill the Telegram App. Re-open it, go to the chat with your target bot, type a / (or tab on the / button next to the text field), the command menu should come up.

like image 127
Nick Lee Avatar answered Sep 28 '22 08:09

Nick Lee


New dynamic way to set commands

Telegram introduced a separate method setMyCommands which allows you to set commands via API directly from your code.

{   "commands": [     {       "command": "start",       "description": "Start using bot"     },     {       "command": "help",       "description": "Display help"     },     {       "command": "menu",       "description": "Display menu"     }   ],   "language_code": "en" } 

Moreover, it allows you to customize commands per language code with language_code parameter

like image 21
Andrii Abramov Avatar answered Sep 28 '22 09:09

Andrii Abramov