xBytez / slackbotapi

node.js Slack RTM API module
GNU Lesser General Public License v3.0
135 stars 40 forks source link

request: support for attachments #24

Closed ghostsquad closed 9 years ago

ghostsquad commented 9 years ago

https://api.slack.com/docs/attachments

xBytez commented 9 years ago

The RTM API only supports posting simple messages formatted using our default message formatting mode. It does not support attachments or other message formatting modes. To post a more complex message as a user clients can call the chat.postMessage Web API method with as_user set to true.

-- https://api.slack.com/rtm

HOWEVER! In the API there is a way to send requests using the Web API method. I added this to my commands switch.

case "debugpost":
    var payload = {
        "attachments": [
            {
                "fallback": "Fall back for notificaiton",
                "pretext": "PRETEXT",
                "title": "TITLE",
                "title_link": "TITLE LINK",
                "text": "woo! attachments",
                "color": "#7CD197"
            }
        ],
        "username": "USERNAME",
        "channel": data.channel,
        "icon_url": "http://i.imgur.com/hAfHdi3.png"
    };
    slack.reqAPI('chat.postMessage', payload, function(data) {
        // do stuff
    });
break;

Screenshot

I hope this is what you wanted.

ghostsquad commented 9 years ago

This is exactly what I was looking for. Thanks!

On Fri, Aug 28, 2015 at 2:12 PM xBytez notifications@github.com wrote:

Closed #24 https://github.com/xBytez/slackbotapi/issues/24.

— Reply to this email directly or view it on GitHub https://github.com/xBytez/slackbotapi/issues/24#event-395487630.