Skip to content

Commit

Permalink
Merge pull request #6 from rafaelgaspar/webhook-url
Browse files Browse the repository at this point in the history
Support for webhook url instead of company name and token.
  • Loading branch information
esanchezm committed Feb 11, 2015
2 parents cac4647 + 5927fe6 commit 0101878
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ git clone https://github.com/esanchezm/amazon-cloudwatch-to-slack.git

cd amazon-cloudwatch-to-slack
heroku apps:create
heroku config:set SLACK_COMPANY_NAME=yourcompany \
SLACK_TOKEN=12345 \
heroku config:set 'SLACK_WEBHOOK_URL=https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX'
git push heroku master
```

Expand All @@ -32,7 +31,7 @@ You can optionally set a diferent slack channel, username or avatar to customize
```
heroku config:set SLACK_CHANNEL=#yourchannel\
SLACK_USERNAME="AWS CloudWatch" \
SLACK_ICON_URL="http://www.example.com/bot_avatar.png"
SLACK_ICON_URL="http://www.example.com/bot_avatar.png" \
SLACK_ICON_EMOJI=":ghost:"
```

Expand All @@ -43,10 +42,10 @@ Additional configuration parameters for SES notifications:
```
heroku config:set SLACK_SES_CHANNEL=#otherchannel\
SLACK_SES_USERNAME="AWS SES" \
SLACK_SES_ICON_URL="http://www.example.com/bot_avatar.png"
SLACK_SES_ICON_URL="http://www.example.com/bot_avatar.png" \
SLACK_SES_ICON_EMOJI=":ghost:"
```


Or just push the button:

[![Deploy](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy)
Expand Down
15 changes: 10 additions & 5 deletions routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,16 @@ exports.index = function(req, res) {
payload = process_ses_delivery_notification(json_message);
}

var slackUrl =
'https://' +
process.env.SLACK_COMPANY_NAME +
'.slack.com/services/hooks/incoming-webhook?token=' +
process.env.SLACK_TOKEN;
var slackUrl;
if (typeof process.env.SLACK_WEBHOOK_URL != "undefined") {
slackUrl = process.env.SLACK_WEBHOOK_URL;
} else {
slackUrl =
'https://' +
process.env.SLACK_COMPANY_NAME +
'.slack.com/services/hooks/incoming-webhook?token=' +
process.env.SLACK_TOKEN;
}

if (typeof process.env.SLACK_USERNAME != "undefined") {
payload["username"] = process.env.SLACK_USERNAME;
Expand Down

0 comments on commit 0101878

Please sign in to comment.