【发布时间】:2017-02-07 10:28:52
【问题描述】:
我使用 node.js 来构建我的 slack 机器人。我用@slack/client。它工作正常。
现在我有一个通过slack message builder 获得的 JSON 格式的数据。
像这样,
{
"attachments": [
{
"fallback": "Required plain-text summary of the attachment.",
"color": "#36a64f",
"pretext": "Optional text that appears above the attachment block",
"author_name": "Bobby Tables",
"author_link": "http://flickr.com/bobby/",
"author_icon": "http://flickr.com/icons/bobby.jpg",
"title": "Slack API Documentation",
"title_link": "https://api.slack.com/",
"text": "Optional text that appears within the attachment",
"fields": [
{
"title": "Priority",
"value": "High",
"short": false
}
],
"image_url": "http://my-website.com/path/to/image.jpg",
"thumb_url": "http://example.com/path/to/thumb.png",
"footer": "Slack API",
"footer_icon": "https://platform.slack-edge.com/img/default_application_icon.png",
"ts": 123456789
}
]
}
如果我通过显示 json 文本的 rtm.sendMessage() 函数发送此 json。如何将此 json 转换为格式化的松弛消息?提前致谢。
【问题讨论】:
标签: json node.js slack-api slack