Warning appears alongside Slack button after click

536 views Asked by At

I'm using Slack and Slack Bolt to display buttons in a message, but those buttons are just used as links, redirecting to my web app. Whenever a user clicks a button, it works as intended but a warning icon appears alongside the button.

This issue is already described here but more specifically on the Slack API repository. But if I'm understanding it correctly, the solution proposed (the dummy handler) can be used only if the request goes through the server, which is not the case here.

Here's the code creating the buttons :

export function buildButton(
  text: string,
  href: string,
  actionId?: string
): Button {
  if (actionId) {
    return {
      type: "button",
      text: {
        type: "plain_text",
        emoji: true,
        text: text,
      },
      url: href,
      action_id: actionId,
    };
  }
  return {
    type: "button",
    text: {
      type: "plain_text",
      emoji: true,
      text: text,
    },
    url: href,
  };
}

So, is there any other solution than just using a plain link instead of a button ?

1

There are 1 answers

0
cborch On

The warning icon appears because slack is expecting your app to ack the action dispatched by the button press within 3 seconds. If you're only using the button as a link, you can simply ack the action from within your app. This will stop the warning icon from appearing.

app.action('your_action_id', async ({ ack }) => {
  await ack();
});