Slack.postToChannel()

Post a message to the specified channel in Slack.

Unless otherwise configured, this machine posts to the "#general" channel.

Usage

Hover over inputs/exits for more info.

var Slack = require('machinepack-slack');


// Post a message to the specified channel in Slack.

Slack.postToChannel({

webhookUrl: 'https://hooks.slack.com/services/xxxxyyyy/ZZZZZZZZ/XXXXXXXXXXXXXXX',

channel: '#general',

message: 'Good morning, boys and girls!',

username: 'someboty',

iconEmoji: ':ghost:',

linkNames: true,

}).exec({

// An unexpected error occurred.

error: function (err) {

 

},

// Specified subdomain and webhook token combination does not match any known Slack accounts

notFound: function () {

 

},

// OK.

success: function () {

 

},

});

Inputs

webhookUrl required

A Slack webhook URL

'https://hooks.slack.com/services/xxxxyyyy/ZZZZZZZZ/XXXXXXXXXXXXXXX'
channel required

The Slack channel where the post should be sent

'#general'
message required

The message to post

'Good morning, boys and girls!'
username

The username to use when posting

'someboty'
iconEmoji

The bot icon to display next to the post.

':ghost:'
linkNames

Whether or not create links out of channel names and usernames

true

Exits

error

An unexpected error occurred.

notFound

Specified subdomain and webhook token combination does not match any known Slack accounts

success

OK.