question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

inlineKeyboard not working

See original GitHub issue

I am trying to implement an inlineKeyboard in my Telegram bot, but keep getting following error:

TelegramError: sendMessage failed: Bad Request: field “inline_keyboard” of the InlineKeyboardMarkup should be an Array of Arrays

I have tried with the example you provided in the docs, but keep getting the same error.

// People who are allowed to manipulate the volume
var ALLOWED_SENDERS = [ 8951984, 5091503, ... ];

bot.command("volumeknob", function (msg, reply, next) {
  reply.inlineKeyboard([
    { text: "↑  Turn up", data: JSON.stringify({ type: "volume", direction: true }) },
    { text: "↓  Turn down", data: JSON.stringify({ type: "volume", direction: false }) },
  ]);
  reply.text("Use the buttons below to modify the volume:");
});

bot.callback(function (query, next) {
  // Try to parse payload data as JSON. If we succeed, and `type` is set
  // to "volume" then the query is for us.
  var data;
  try {
    data = JSON.parse(query.data);
  } catch (e) {
    return next();
  }
  if (data.type !== "volume")
    return next();

  // Check sender is in whitelist
  if (ALLOWED_SENDERS.indexOf(query.from.id) === -1)
    return query.answer({ text: "Permission denied." });
  
  // Turn volume up or down
  if (data.direction) {
    system.volumeUp();
    query.answer();
  } else {
    system.volumeDown();
    query.answer();
  }
});

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
mildsunrisecommented, Jul 28, 2017

Closing issue, then. By the way, I added the actions.js example which also uses inline keyboards.

1reaction
mildsunrisecommented, Jul 28, 2017

Whooops, again my bad. It was callback_data instead of data. I have corrected the example code in the docs, it should work now.

I’ve also added a functional delete_echo.js example, you can look at it as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

php - Telegram bot inline keyboard callback not working
When I click on the inline keyboard button, nothing responds, why it's happening? Please help me to fix the issues. $update = file_get_contents ......
Read more >
Telegram Inline Keyboard commands not working on Android
I was wondering if somebody uses “Inline Keyboard” with Telegram and Android. In general, telegram commands are working for me: service: notify.
Read more >
callback not working with version 3.4 · Issue #955 - GitHub
It show nothing when I click on inline keyboard. I have use all this in my custom command handle. use Telegram; use Telegram\Bot\Commands\Command;...
Read more >
Problem with inline keyboard buttons : r/TelegramBots - Reddit
Problem with inline keyboard buttons. Helloooo folks. I'm trying to build a telegram bot with the API and Telegraf on the typescript, ...
Read more >
Telegram Bot API
This method will not work if an outgoing webhook is set up. ... Inline keyboard attached to the message. login_url buttons are represented...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found