Hubot x Slack,製作自動回話與工作的機器人

Hubot x Slack,製作自動回話與工作的機器人 Hubot x Slack 串接紀錄。

安裝 Hubot

按照官方文件的指示一步步安裝。安裝完後,便可用command line與robot互動。使用 bin/hubot 啟動robot。可以使用 hubot help 看看預設有什麼功能可以使用。

安裝 Hubot 的 Slack Adapter

按照hubot-slack安裝 Hubot 的 Slack Adapter。安裝完後,要到Slack的Hubot App設定。這邊因為找了滿久的,所以截圖詳細記錄一下。

Slack的Hubot App設定

先從「Apps & integrations」到「App Directory」,然後搜尋「hubot」。

Apps & integrations

Apps & integrations

App Directory,搜尋「hubot」

App Directory

新增app

hubot app

這邊因為我已經新增好了,所以只能截圖設定完畢的樣子。

取得token

啟動robot時必須附上token。

取得token

準備腳本

在scripts資料夾裡面新增script.js,然後寫些簡單的腳本。

module.exports = function(bot){
  bot.respond(/你好嗎?/, function(res){
    res.send('很開心 ^^');
  });
}

連線

使用指令「HUBOTSLACKTOKEN=xoxb-9999999999-abcdefghijklmnop ./bin/hubot --adapter slack」連線。xoxb-9999999999-abcdefghijklmnop 這裡代入剛剛取得的token即可。

看到Slack聊天室裡機器人的綠燈亮了,就表示成功了噢!

測試

測試


由於部落格搬家了,因此在新落格也放了一份,未來若有增刪會在這裡更新-Hubot x Slack,製作自動回話與工作的機器人

留言