Slack Incoming WebHook for Facebook
npm install -g slack-incoming-facebook
slack-incoming-facebook \
--config /path/to/config.json \
--db /path/to/db.json \
--env environment
{
"development": {
"facebook": {
"id": "[Organization Screen Name]",
"token": "[OAuth Access Token]",
"types": ["post types to include (optional)"]
},
"slack": { "see below" }
}
}
The username
, icon_url
and channel
keys are optional and take effect only if the hook is a Custom Integration. These 3 keys have no effect for bundled OAuth Apps.
Single hook:
"slack": {
"hook": "[Hook URL]",
"username": "[App Name]",
"icon_url": "[App Avatar]",
"channel": "[Target #channel or @user]"
}
Multiple hooks with a common
username
,icon_url
andchannel
configuration:
"slack": {
"hook": [
"[Hook URL 1]",
"[Hook URL 2]"
],
"username": "[App Name]",
"icon_url": "[App Avatar]",
"channel": "[Target #channel or @user]"
}
Multiple hooks with separate
username
,icon_url
andchannel
configuration:
"slack": [
{
"hook": "[Hook URL 1]",
"username": "[App Name]",
"icon_url": "[App Avatar]",
"channel": "[Target #channel or @user]"
},
{
"hook": [
"[Hook URL 2]",
"[Hook URL 3]"
],
"username": "[App Name]",
"icon_url": "[App Avatar]",
"channel": "[Target #channel or @user]"
}
]
{
"development": {
"timestamp": 0
},
"production": {
"timestamp": 0
}
}
# Run on every 15 min:
*/15 * * * * node slack-incoming-facebook [params] >> slack-incoming-facebook.log
var hook = require('slack-incoming-facebook')
hook({
config: require('config.json'),
db: require('db.json'),
dpath: '/absolute/path/to/db.json',
env: 'development'
})
.then((responses) => {
responses.forEach(([res, body]) => {
console.log(new Date().toString(), res.statusCode, body)
})
})
.catch((err) => console.error(new Date().toString(), err))