Issues with callback_query in node-telegram-bot-api

I am currently developing a bot in NodeJS and have reached the stage where I need to handle callback_query. However, the bot fails to respond when I click on the inline keyboard options.

Version Details:

"node-telegram-bot-api": "^0.66.0"

Example Code:

import TelegramBot from "node-telegram-bot-api";
import { config } from "dotenv";

config();
const BOT_API_KEY = process.env.TOKEN;

const bot = new TelegramBot(BOT_API_KEY, { polling: true });

const optionsForGame = {
  reply_markup: {
    inline_keyboard: [
      [{text: 'A', callback_data:'A'}, {text: 'B', callback_data:'B'}, {text: 'C', callback_data:'C'}],
      [{text: 'D', callback_data:'D'}, {text: 'E', callback_data:'E'}, {text: 'F', callback_data:'F'}],
      [{text: 'G', callback_data:'G'}, {text: 'H', callback_data:'H'}, {text: 'I', callback_data:'I'}],
      [{text: 'J', callback_data:'J'}]
    ]
  }
};

function initializeBot() {
  const gameSessions = {};
  bot.setMyCommands([
    { command: '/begin', description: 'Start the bot' },
    { command: '/play', description: 'Play a game' }
  ]);

  bot.on('message', async (msg) => {
    const incomingText = msg.text;
    const chatId = msg.chat.id;
    
    if (incomingText === '/begin') {
      return await bot.sendMessage(chatId, `You sent: ${incomingText}`);
    }
    if (incomingText === '/play') {
      await bot.sendMessage(chatId, 'I will think of a letter from A to J');
      const randomLetter = String.fromCharCode(65 + Math.floor(Math.random() * 10));
      gameSessions[chatId] = randomLetter;
      console.log(optionsForGame);
      return await bot.sendMessage(chatId, "Your guess is needed:", optionsForGame);
    }
    return await bot.sendMessage(chatId, 'Sorry, I did not understand that.');
  });

  bot.on('callback_query', (callbackQuery) => {
    console.log(callbackQuery);
  });
}
initializeBot();

Another thing to check is whether the bot is being run with updated security settings and appropriate access. It’s also worth mentioning that sometimes issues arise from extended polling timeout settings. Make sure the bot is not getting disconnected due to network issues or long periods of inactivity. Lastly, ensure your inline keyboard buttons have unique callback data if you plan on handling them specifically, so the backend logic can accurately track each button press.

Hey, have u checked if the bot has the right permissions? Sometimes it won’t respond if it’s blocked from reading certain messages. Also try logging inside the callback_query to see if it’s even hit. Hope it helps!