我正在尝试使用传入 Webhook 通过私有 Slack 文件发布消息。
采取的步骤:
请求正文:
{
"text": "Danny Torrence left a 1 star review for your property.",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Danny Torrence left the following review for your property:"
}
},
{
"type": "section",
"block_id": "section567",
"text": {
"type": "mrkdwn",
"text": "<https://example.com|Overlook Hotel> \n :star: \n Doors had too many axe holes, guest in room 237 was far too rowdy, whole place felt stuck in the 1920s."
},
"accessory": {
"type": "image",
"image_url": "https://is5-ssl.mzstatic.com/image/thumb/Purple3/v4/d3/72/5c/d3725c8f-c642-5d69-1904-aa36e4297885/source/256x256bb.jpg",
"alt_text": "Haunted hotel image"
}
},
{
"type": "section",
"block_id": "section789",
"fields": [
{
"type": "mrkdwn",
"text": "*Average Rating*\n1.0"
}
]
},
{
"type": "image",
"title": {
"type": "plain_text",
"text": "Please enjoy this photo of a kitten"
},
"block_id": "image4",
"slack_file": {
"url": "https://files.slack.com/files-pri/00000000000-00000000000/testphoto.jpg"
},
"alt_text": "An incredibly cute kitten."
}
]
}
我没有尝试过的一件事是使用
sharedPublicURL
API,但我期望的是不要公开共享文件。
我在 Slack 上找到了一篇与我的期望相关的文章: https://slack.com/blog/developers/uploading-private-images-blockkit
所以,我的问题是:
Slack 应用程序集成相当新,如果您需要更多信息,请告诉我。谢谢。
这是我尝试过的:
经过几天的研究和测试,似乎传入的 Webhooks 应用程序(机器人)没有权限访问我的机器人上传的文件(我在上传文件和触发 Webhook 时使用相同的机器人)。我什至尝试通过将文件共享到机器人来将文件上传到机器人本身
Channel ID
,但仍然失败。
我决定使用
chat.postMessage
API here 寻找替代方案,现在效果很好。