Giacomo Lai
Giacomo Lai

Reputation: 494

TelegramBots Java API - Get Chat object from CallbackQuery getChatInstance method

Is there a way to retrieve the chat id from a CallbackQuery object?

In my case, I have made a InlineKeyboardButton and set a callbackQueryData. I'm able to retrieve this callback query but without chance to retrieve the chat id. I know the answerInlineQuery method but I dont need in my case. I need only a way to retrieve the chat id.

CallbackQuery class provide the getChatInstance() method but return always null.

Anyone can help me?

Thank you

Upvotes: 0

Views: 1582

Answers (1)

Giacomo Lai
Giacomo Lai

Reputation: 494

SOLUTION FOUND

CallbackQuery callbackQuery;
Long chatId = callbackQuery.getMessage().getChatId();

Upvotes: 1

Related Questions