チラシの裏

SlackとHubotを連携してHerokuにデプロイ

2014.09.24

前回 の続き

参考サイト:https://github.com/tinyspeck/hubot-slack

Hubotを作る

  • Hubotを作る
$ hubot --create mybot
$ cd mybot
  • アダプターをインストール
$ npm install hubot-slack --save

package.json のdependenciesにhubot-slackが追加される

  • Redisを使わないように hubot-scripts.json を更新
["shipit.coffee"]

Herokuにデプロイ

  • Procfileを更新する
web: bin/hubot --adapter slack
  • heroku toolbeltをインストールする

macなら

$ brew install heroku-toolbelt
  • Herokuのプロジェクト作成
$ heroku create my-bot
  • SlackのIntegrationを追加して必要なトークンを取得
https://<your-team>.slack.com/services/new/hubot
  • トークンを設定
$ heroku config:add HEROKU_URL=http://<your-project>.herokuapp.com
$ heroku config:add HUBOT_SLACK_TOKEN=*****************
$ heroku config:add HUBOT_SLACK_TEAM=myteam
$ heroku config:add HUBOT_SLACK_BOTNAME=slackbot
  • タイムゾーンの設定
$ heroku config:add TZ=Asia/Tokyo
  • デプロイ
$ git init
$ git add .
$ git commit -m "first commit"
$ git remote add heroku [email protected]:<your-project>.git
$ git push heroku master
$ heroku ps:scale web=1

これでHubotが反応してくれれば終了

Hubotが反応しない場合

bash: bin/hubot: No such file or directory

binディレクトリがcommitされていますか?

私の場合、グローバルの.gitignoreでbinディレクトリを除外していたためbinディレクトリがcommitできずに上記のエラーがでていました。

comments powered by Disqus