[Telegram Binding] "The received callback query dummy has not the right format"

Hi there,
at the moment im using Telegram with OH and i love the possibilites it gives me.

Im sending myself reminders with a Bot from a Google Spreadsheets App Script.
The code looks like this:

  UrlFetchApp.fetch('https://api.telegram.org/bot' + token + '/', data);
  var data = {
    method: "post",
    payload: {
      method: "sendMessage",
      chat_id: String(id),
      text: text,
      reply_markup: JSON.stringify({"inline_keyboard": [[{"text": "DONE","callback_data":"dummy"}]]}),
      parse_mode: "HTML",

  UrlFetchApp.fetch('https://api.telegram.org/bot' + token + '/', data);

It just generates a reminder Message with a inline keyboard button below which says “DONE” and has callback data “dummy”.

At the moment i think, that if i want the DONE button to disappear after klicking (and thats the only thing i want), i must have some service listen to the Current Bot ansers and reply to the callback_data “dummy” → This should let the button disappear

This already works by just using the Telegram binding

But in this case (when the inital message was created from the Spreadsheet-Script), frontail shows

[ng.telegram.internal.TelegramHandler] - The received callback query dummy has not the right format (must be seperated by spaces)

after i clicked the DONE button

Can anyone give me a hint how i could change my App Script, that Telegram-Binding does not have a problem with the content?


Cannot give a hint what exactly needs to be changed but the telegram binding shows this source code around the error message that is being created:

            } else if (callbackQuery != null && callbackQuery.message() != null
                    && callbackQuery.message().text() != null) {
                String[] callbackData = callbackQuery.data().split(" ", 2);

               if (callbackData.length == 2) {
                    replyId = callbackData[0];
                    lastMessageText = callbackData[1];
                    lastMessageDate = callbackQuery.message().date();
                    lastMessageFirstName = callbackQuery.from().firstName();
                    lastMessageLastName = callbackQuery.from().lastName();
                    lastMessageUsername = callbackQuery.from().username();
                    chatId = callbackQuery.message().chat().id();
                    replyIdToCallbackId.put(new ReplyKey(chatId, replyId), callbackQuery.id());

                    // build and publish callbackEvent trigger channel payload
                    JsonObject callbackRaw = JsonParser.parseString(gson.toJson(callbackQuery)).getAsJsonObject();
                    JsonObject callbackPayload = new JsonObject();
                    callbackPayload.addProperty("message_id", callbackQuery.message().messageId());
                    callbackPayload.addProperty("from", lastMessageFirstName + " " + lastMessageLastName);
                    callbackPayload.addProperty("chat_id", callbackQuery.message().chat().id());
                    callbackPayload.addProperty("callback_id", callbackQuery.id());
                    callbackPayload.addProperty("reply_id", callbackData[0]);
                    callbackPayload.addProperty("text", callbackData[1]);
                    triggerEvent(CALLBACKEVENT, callbackPayload.toString());
                    triggerEvent(CALLBACKRAWEVENT, callbackRaw.toString());

                    logger.debug("Received callbackId {} for chatId {} and replyId {}", callbackQuery.id(), chatId,
                } else {
                    logger.warn("The received callback query {} has not the right format (must be seperated by spaces)",

So as far as I understand “callbackQuery.data().split(” “, 2)” splits into an array with two elements.
The check for 2 elements fails and the error message is created.

1 Like

I was guessing something like this!
Could you just tell me the path to the file where it is located? Before i created this post i was trying to find it myself but im not a github-pro and was to blind to find :sweat_smile:

Thanks to you i have not a chance :wink:

git clone https://github.com/openhab/openhab-addons.git
cd openhab-addons/bundles/org.openhab.binding.telegram
vi ./src/main/java/org/openhab/binding/telegram/internal/TelegramHandler.java
1 Like

OK via comparison of a callback i created and one that openHAB created, it seems that the callback_data used via openhab is sending not only the id but also attaching the button text like this

"text":"BUTTONTEXT","callback_data":"BUTTONTEXT ID"

So there is always a space expected, for using split() command.
I tested using a callback data “dummy dummy” and the error is gone

But now if have a error performing the next step

telegramAction.sendTelegramAnswer(jReplyId.state.toString, "OK!")

which says

messageId not defined; action skipped.


CheckTelegram binding - advanced callback query response.
Document says:

This binding stores the callbackId and recalls it using the replyId, but this information is lost if openHAB restarts. If you store the callbackId, chatId, and optionally messageId somewhere that will be persisted when openHAB shuts down, you can use the following overload of sendTelegramAnswer to respond to any Callback Query.

This seems to apply because you started the callback query from outside of OH.
The code that raises the error message is in

    @RuleAction(label = "send an answer", description = "Send a Telegram answer using the Telegram API.")
    public boolean sendTelegramAnswer(@ActionInput(name = "chatId") @Nullable Long chatId,
            @ActionInput(name = "callbackId") @Nullable String callbackId,
            @ActionInput(name = "messageId") @Nullable Long messageId,
            @ActionInput(name = "message") @Nullable String message) {
        if (chatId == null) {
            logger.warn("chatId not defined; action skipped.");
            return false;
        if (messageId == null) {
            logger.warn("messageId not defined; action skipped.");
            return false;

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.