Search code examples
javaslackbolt

Slack development


Click Yes button

Question: When I click the 'Yes' button, a message will appear under the button, but after a period of time, the message will disappear automatically. Why? How to solve this problem? The code is as follows:

//
app.blockAction("button-action", (req, ctx) -> {
  String value = req.getPayload().getActions().get(0).getValue(); // "button's value"
  if (req.getPayload().getResponseUrl() != null) {
    // Post a message to the same channel if it's a block in a message
    ctx.respond("You've sent " + value + " by clicking the button!");
  }
  return ctx.ack();
});

Solution

  • The message might be disappearing because it is an ephemeral message.
    enter image description here

    As to why this is ephemeral, the reason lies within the implementation of the solution.