• Home
  • Akiko Yokoyama
  • Contact
  • Feed
ja | en |

Setting hubot adapter slack & chatwork

How to link Slack and chatwork after installing hubot

What’s Adapter?

ref. hubot/adapters.md at master · hubotio/hubot

Connect to Slack

install Adapter hubot-slack

1
$ npm install hubot-slack --save

install Adapter hubot-chatwork

1
$ npm install hubot-chatwork --save

setting system enviorment

create new shell script in the hubot directory.

1
2
3
4
5
6
7
8
# slack
export HUBOT_SLACK_TOKEN=[API_TOKEN]

# chatwork
export HUBOT_CHATWORK_TOKEN="[CHATWORK_TOKEN]"
export HUBOT_CHATWORK_ROOMS="[CHATWORK_ROOM_ID]"
export HUBOT_CHATWORK_API_RATE="350"

Start hubot for slack

1
$ ./bin/hubot -a slack -n sample-hubot

Start hubot for chatwork

1
$ ./bin/hubot -a chatwork -n sample-hubot

create new scripts

create sample script and a little something extra

scripts/posting-sample.coffee

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
module.exports = (robot) ->

  robot.hear /badger/i, (res) ->
    res.send "Yes, more badgers please!"

  robot.hear /I like pie/i, (res) ->
    res.send "makes a freshly baked pie"

  robot.hear /hello/i, (res) ->
    res.reply "Hello  #{res.message.user.profile.first_name}"

  robot.hear /get random color/i, (res) ->
    colors = ['red', 'blue', 'yellow', 'white', 'black']
    res.reply res.random colors

reply to message in chatwork

1
2
3
4
5
6
module.exports = (robot) ->

  robot.hear /(\[To:12345678\]*)/i, (msg) ->
    envelope = room: process.env.HUBOT_CHATWORK_ROOMS
    sendMsg = "Hi, I'm bot :)"
    robot.send envelope, sendMsg
user-image
Akiko yokoyama in Coding
5 minute read

Similar Posts

Actually Made This Blog Multilingual Three Years Ago

Review of the Leica Q2

Re-Builded the Blog with Jekyll + Netlify + Github

Excel Tips vol.1

Setup for WSL / Windows Subsystem for Linux + Ubuntu

user-image

Published Mar 15, 2018

Akiko yokoyama in Coding

Also found in

  • Coding

Share this article

Actually Made This Blog Multilingual Three Years Ago

Review of the Leica Q2

Re-Builded the Blog with Jekyll + Netlify + Github

Excel Tips vol.1

Setup for WSL / Windows Subsystem for Linux + Ubuntu

How to install and setting hubot

  • Home
  • Akiko Yokoyama
  • Contact
  • Feed