LoginSignup
0
1

More than 5 years have passed since last update.

今日からherokuでhubot運用

Posted at

背景

bot運用サーバー解約に伴って、移行ついでに heroku ってみる。

結論

先に結論を言うと無料でもhubotの運用はできる。はず。

では始めましょう

1. Sign up on heroku
https://www.heroku.com
クレジットカードの入力するだけで+450hの稼働時間をもられるのと、あとで使うaddon使えるようになるので入れましょう。

2. Install heroku cmd
https://devcenter.heroku.com/articles/heroku-cli
パッケージ取得してherokuコマンドインストール

3. Create Project

$ heroku login
$ mkdir -p ~Dev/Heroku/hubot
$ cd ~Dev/Heroku/hubot

4. Install hubot

$ npm install -g yo generator-hubot
$ yo hubot
$ bin/hubot --name unko

5. Push to heroku

$ git init
$ git add .
$ git commit -m 'first'
$ heroku create
$ vim Procfile
Procfile
web: bin/hubot --adapter slack
$ git push heroku master

6. Get Token of Slack
slackにてHubotを有効にして、tokenを取得

7. Set Config for heroku

heroku config:set HUBOT_SLACK_TOKEN={SLACK_TOKEN}
heroku config:set HUBOT_HEROKU_KEEPALIVE_URL={HEROKU_URL}

8. Let's Try

on_slack
@unko image me banana

名称未設定.png

9. Set Custom Search on google
[下記を参照してください。]
http://qiita.com/hoto17296/items/f27ebf62c6015befdaa8
https://github.com/hubot-scripts/hubot-google-images#cse-setup-details

10. Set CSE Conf

heroku config:set HUBOT_GOOGLE_CSE_ID={CSE_ID}
heroku config:set HUBOT_GOOGLE_CSE_KEY={CSE_KEY}

11. Set Schedule Conf
bot君は定時退社

$ heroku config:add HUBOT_HEROKU_WAKEUP_TIME=9:30
$ heroku config:add HUBOT_HEROKU_SLEEP_TIME=18:30
$ heroku config:add TZ='Asia/Tokyo'
$ heroku addons:create scheduler:standard
$ heroku addons:open scheduler

12. Set the Schedule Detail
タイムゾーンはUTCなのでJSTから-9hした値を入れてください。
Heroku Scheduler.png

終わり

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1