How can I get InlineKeyboardCallbackButton clicked in telegram bot?
Here is my code : I Edited The Code
public async System.Threading.Tasks.Task<ActionResult> GetMsgAsync()
{
var req = Request.InputStream;
var responsString = new StreamReader(req).ReadToEnd();
var update = JsonConvert.DeserializeObject<Update>(responsString);
var message = update.Message;
var chat = message.Chat;
InlineKeyboardMarkup categoryInlineMarkup = new
InlineKeyboardMarkup(
new InlineKeyboardButton[][]
{
new InlineKeyboardButton[]
{
new InlineKeyboardCallbackButton("button1","callbackData")
}
}
);
await api.SendTextMessageAsync(update.Message.Chat.Id, "Please click the button", replyMarkup: categoryInlineMarkup);
if (update.Type == Telegram.Bot.Types.Enums.UpdateType.MessageUpdate)
{
// all codes just run in this block
}
if (update.Type == Telegram.Bot.Types.Enums.UpdateType.CallbackQueryUpdate)
{
// I can't get clicked button here
if (update.CallbackQuery.Data.Contains("callbackData"))
{
await api.AnswerCallbackQueryAsync(update.CallbackQuery.Id, update.CallbackQuery.Data);
}
}
}
How can I get this button clicked also in webhook method, not in console program?
Finally i find out the answer, the problem is this line of code :
After this Problem, i have a suggestion for you
You can debugging your telegram bot in your personal computer without uploading any code on any host, for this purpose You can run 3 below steps ::
1- Accessing an IIS Express site from a remote computer
2- Download NGROK
3- after download ngrok you can forward telegram webhook requests to your personal computer .