python version 3.8.3
import telegram #imorted methodts
from telegram.ext import Updater, CommandHandler
import requests
from telegram import ReplyKeyboardMarkup, KeyboardButton
from telegram.ext.messagehandler import MessageHandler
import json
# below is function defined the buttons to be return
def start(bot, update):
button1 = KeyboardButton("hello")
button2 = KeyboardButton("by")
keyboard = [button1, button2]
reply_markup = telegram.ReplyKeyboardMarkup(keyboard)
chat_id = update.message.chat_id
bot.send_message(chat_id=chat_id, text='please choose USD or EUR', reply_markup = reply_markup) # it works and returns text if reply_markup parameter disabled.
def main():
updater = Updater('my token')
dp = updater.dispatcher
dp.add_handler(CommandHandler('start', start))
updater.start_polling()
updater.idle()
main()
buttons are not working. Please help to check what could be the reason of this issue.
2
Answers
try using string instead of keyboard button:
Add logging, so you’ll be able to see if there are any errors or response with error there.