English 中文(简体)
无法删除通过接收 Webhoooks 发送的信件
原标题:Unable to delete a message sent via Incoming Webhooks
I am using Slack Incoming Webhooks requests to post messages to a Slack channel from an app. I love it since I can send messages directly from shell scripts. However going further I stumble into the problem that I seem to be unable to delete messages. The app has two access tokens: An OAuth access token xoxp-012345678901-012345678901-012345678901-0123456789abcdef0123456789abcdef (this is a fictitious token but the length is the same as the actual token). Bot User OAuth access token xoxb-012345678901-012345678901-0123456789abcdef01234567. Using the xoxp- OAuth access token I can retrieve channel history. curl "https://slack.com/api/channels.history?token=xoxp-012345678901-012345678901-012345678901-0123456789abcdef0123456789abcdef&channel=CABCDABCD&count=20&pretty=1" With the xoxb- token the channels.history request fails with { "ok": false, "error": "not_in_channel" } In chat history I have a message that I would like to delete. The message was posted using Incoming Webhooks associated with the App. { "type": "message", "subtype": "bot_message", "text": ":heavy_check_mark:", "ts": "1580968882.000800", "bot_id": "BABCDABCD", "blocks": [ { "type": "section", "block_id": "5Ov", "text": { "type": "mrkdwn", "text": "text of the message to delete", "verbatim": false } } ] } However neither token works with chat.delete. Both curl "https://slack.com/api/chat.delete?token=xoxb-012345678901-012345678901-0123456789abcdef01234567&channel=CABCDABCD&ts=1580968882.000800&pretty=1" and curl "https://slack.com/api/chat.delete?token=xoxp-012345678901-012345678901-012345678901-0123456789abcdef0123456789abcdef&channel=CABCDABCD&ts=1580968882.000800&pretty=1" fail with { "ok": false, "error": "cant_delete_message" } And the question is: Is there a way to delete a message posted by an app via Incoming Webhooks requests? PS. Both chat:write:bot and chat:write:user permissions are granted.
问题回答
Yes, but the token owner needs to be admin in order to have the right to delete message of other users / apps. To clarify: This has nothing to do with OAuth scopes, but with the Slack role of the user who owns the token.
Incoming webhooks do not allow you to delete a message after it s been posted. If you need a more complex chat flow including message deletion, call chat.postMessage. https://api.slack.com/messaging/webhooks




相关问题
Using Starts with to find the key of a List

I have a list of objects, one of them is appended dynamically upstream and then passed in an array list. I need to fetch out this key (it looks like this: status_block_EPOCH) but when I try to filter ...

AI Chatbot Implementation and integration with Slack

I have to build a chatbot based on my compnay data. The data is in a pdf file. I want the chatbot to be trained in such a way that it answers any query that has an answer in the document. I dont want ...

Slack-Bolt Python API not picking up messages correctly?

I am trying to use the Slack-bolt API for Python to listen to DMs to the slack bot that contain specific text. Here is my file that initiates the Slack-Bolt listener: import os from server import * ...

Listing channels that Slackbot is a member of

I have a small script which uses the slack API to create group chats with users and send an intro message. There are around ~100 of these group chats that I have created, but unfortunately I only ...

热门标签