Skip to content

Instantly share code, notes, and snippets.

@loisaidasam
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loisaidasam/fc7da40b184828c10d8c to your computer and use it in GitHub Desktop.
Save loisaidasam/fc7da40b184828c10d8c to your computer and use it in GitHub Desktop.
A script for testing your Hubot's Slack webhook
#!/bin/bash
HEROKU_URL="$1"
if [ -z "$HEROKU_URL" ] ; then
HEROKU_URL=`heroku config:get HEROKU_URL`
fi
SLACK_URI="$HEROKU_URL/hubot/slack-webhook"
CODE=`curl -sL -w "%{http_code}" -o /dev/null -d "" "$SLACK_URI"`
echo "POST to $SLACK_URI code $CODE" >&2
if [ "$CODE" -ne "200" ] ; then
echo "not cool" >&2
exit 1
fi
echo "cool" >&2
@loisaidasam
Copy link
Author

Test whether a Heroku-hosted Hubot with a Slack adapter has a correctly-behaving webhook.

$ ./hubot_slack_test.sh 
POST to http://your-hubot-name-here.herokuapp.com/hubot/slack-webhook code 200
cool

A few notes:

  • these messages sent to stderr (helpful for using this in a crontab, for instance)
  • return code will be 0 on success, 1 on failure (helpful for chaining with other scripts)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment