2017-02-07 7 views
2

私はスラックボットを構築するためにnode.jsを使用しました。私は@slack/clientを使用しました。その作品は大丈夫です。 今私はslack message builderを介して得られたJSON形式のデータを持っています。私は、JSONテキストを表示するrtm.sendMessage()機能を通じて、このJSONを送信する場合、このような 、スラックRTMメッセージ

{ 
    "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をフォーマットされたスラックメッセージに変換するのですか?前もって感謝します。

答えて

0
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

ご質問がある場合は、 –

+0

にお問い合わせください。わかった。 –

関連する問題