title: How can I answer to callback in Java telegram bot?
body: <p>I'm writing a Java bot with <a href="https://github.com/rubenlagus/TelegramBots" rel="nofollow noreferrer">https://github.com/rubenlagus/TelegramBots</a>, and I have a problem, when I click inline keyboard button, this little clock:<br />
  <a href="https://i.stack.imgur.com/qhDT7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qhDT7.png" alt="clock" /></a> appears and after some time it says that my bot is not responding. My bot is actually fully functional except this one thing. Here is how I receive callbacks:</p>
  <pre><code>@Override
  public void onUpdateReceived(Update update) {
      var messagesToSend = updateReceiver.handle(update);
  
      if (messagesToSend != null &amp;&amp; !messagesToSend.isEmpty()) {
  
          messagesToSend.forEach(response -&gt; {
              if (response instanceof SendMessage) {
                  try {
                      execute((SendMessage) response);
                  } catch (TelegramApiException e) {
                      e.printStackTrace();
                  }
              } else if (response instanceof SendPhoto) {
                  try {
                      execute((SendPhoto) response);
                  } catch (TelegramApiException e) {
                      e.printStackTrace();
                  }
              } else if (response instanceof FileSaveRequest) {
                  FileSaveRequest request = (FileSaveRequest) response;
                  try {
                      saveFile(request);
                  } catch (TelegramApiException | IOException e) {
                      e.printStackTrace();
                  }
              }
          });
      }
  
  }
  </code></pre>
  <p>=
  This is only part of the whole code</p>
  <pre><code> } else if (update.hasCallbackQuery()) {
              final CallbackQuery callbackQuery = update.getCallbackQuery();
              final long chatId = callbackQuery.getFrom().getId();
              final User user = userRepository.findById(chatId)
                      .orElseGet(() -&gt; userRepository.save(new User(chatId)));
  
              AnswerCallbackQuery acceptCallback = new AnswerCallbackQuery();
              acceptCallback.setShowAlert(false);
              acceptCallback.setCallbackQueryId(String.valueOf(update.getCallbackQuery().getId()));
              acceptCallback.setCacheTime(1000);
              List&lt;PartialBotApiMethod&lt;? extends Serializable&gt;&gt; resultList =
                      new ArrayList&lt;&gt;(
                              getHandlerByCallBackQuery(callbackQuery.getData())
                              .handle(user, callbackQuery.getData()));
              resultList.add(acceptCallback);
              return resultList;
          }
  </code></pre>
  <p>As you can see, I still attach AnswerCallbackQuery but it still doesent work. What's wrong?</p>