Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for webhook url instead of company name and token. #6

Merged
merged 2 commits into from
Feb 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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