json - 松弛 RTM 消息

标签 json node.js slack-api slack

我使用 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 转换为格式化的 slack 消息?提前致谢。

最佳答案

There are two ways to send message to slack:
1)rtm.sendMessage('hello ' + user.name + '!', dm.id); and 
2)you can use api.chatpost message api ,using request module which is used to send data .
i am using this in my project you can also view this , how i do that.
check my github https://github.com/shekhartyagi26/slack_Rtm/

关于json - 松弛 RTM 消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42087432/

相关文章:

c - 在 C 中推荐的 JSON 解析器?

mysql - sequelize 嵌套包含 where 子句

node.js - 查询mongo数据库字段值,不返回内容

node.js - Slack 机器人安装以包含自定义表情符号?

javascript - 调用ajax调用localhost时出现Access-Control-Allow-Origin错误

javascript - 无法通过ajax将json数据传递给php

java - 从 google maps DistanceMatrix api 在 android 中解析 JSON

node.js - 使用模块进行 TypeScript 转换

flask - 在 flask 应用程序中运行松弛事件适配器

slack-api - 如何删除临时消息