首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >松弛RTM消息

松弛RTM消息
EN

Stack Overflow用户
提问于 2017-02-07 18:28:52
回答 1查看 414关注 0票数 2

我使用node.js来构建我的slack机器人。我使用了@slack/client。它工作得很好。现在,我有了通过slack message builder获得的JSON格式的数据。像这样,

代码语言:javascript
复制
{
    "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消息?提前谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-02-07 18:45:10

代码语言:javascript
复制
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/
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42087432

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档