This example shows how to program a basic Telegram Bot that uses keyboard buttons to interact with users.
Bots are able to interpret free text input from users, but offering specific suggestions is often more intuitive – this is where custom keyboards can be extremely useful.
Whenever your bot sends a message, it can display a special keyboard with predefined reply options (see ReplyKeyboardMarkup). Telegram apps that receive the message will display your keyboard to the user. Using any of the buttons will immediately send the respective text. This way you can drastically simplify and streamline user interaction with your bot.
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j8
./keyboard_buttons YOUR_BOT_TOKEN
- Open the Telegram mobile app and search BotFather
- Send BotFather a command /newbot
- Follow instructions to create a new Bot
- After you finish the instructions, you will receive a Bot Token, make sure you keep it secured.