I'm creating buttons for a slackbot using something like:
const messageB = {
"attachments": [
{
"text": "Essa mensagem foi útil?",
"callback_id": "button_feedback",
"color": "#3AA3E3",
"attachment_type": "default",
"actions": [
{
"name": "button_click_yes",
"text": "sim",
"type": "button",
"value": "yes"
},
{
"name": "button_click_no",
"text": "não",
"type": "button",
"value": "no"
}
]
}
]
};
But the button remain active after the message was sent, and can be used again by the user. I want to deactivate it, or delete it after it was used. But i can't find about it anywhere in the docs.
Clicking on a button will always fire a request to your Slack app. If you want to remove the button after it was clicked you need to update your original message with a new one that reflects the changed state (e.g. button removed). Its not possible to show deactivated buttons with Slack though, so you need to remove it.
To replace the original message all you need to do is respond to the Slack request with an updated message.
However, it will technically still be possible for users to click on your button twice (e.g. due to network delays), so you app should be able to response to multiple clicks on your buttons by the same user in an appropriate way.
See also here for the official documentation on the topic.
See also here and here for answer on a similar topic.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With