node.js-无法通过Slack API发布消息-获取错误“no_text”
发布时间:2022-04-29 09:49:38 167
相关标签: # java
为什么我会收到错误“no_text”?
下面的Json是有效的,取自slack文档示例。
在里面bot.postMessage(channel, '', params)
如果我填充第二个参数(即用“some_text”替换“”),它会打印“some_text”,但没有附件。
bot.postMessage(channel, 'some_text', params)
-->工作正常,但附件没有出现。
const element = {
"text": "Would you like to play a game?",
"response_type": "in_channel",
"attachments": [
{
"text": "Choose a game to play",
"fallback": "If you could read this message, you'd be choosing something fun to do right now.",
"color": "#3AA3E3",
"attachment_type": "default",
"callback_id": "game_selection",
"actions": [
{
"name": "games_list",
"text": "Pick a game...",
"type": "select",
"options": [
{
"text": "Hearts",
"value": "hearts"
},
{
"text": "Global Thermonuclear War",
"value": "war"
}
]
}
]
}
]
}
console.log('JSON.stringify(element): '+JSON.stringify(element));
params = {
icon_emoji: ':r2:',
attachments: JSON.stringify(element)
}
bot.postMessage(channel, '', params).always(function (data) {...}
特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报