ChatOps: Rocket.chat with Hubot chat bot using docker

April 5th, 2017 Posted by Blog, DevOps, Tips 0 thoughts on “ChatOps: Rocket.chat with Hubot chat bot using docker”

We are going to install Rocket.chat with the github Hubot chat bot.

Create a docker-compose.yml file with:

db:
  image: mongo:3.5.5
  volumes:
    - ./data/runtime/db:/data/db
    - ./data/dump:/dump
  command: mongod --smallfiles

rocketchat:
  image: rocketchat/rocket.chat:0.54.2
  environment:
    - MONGO_URL=mongodb://db:27017/rocketchat
    - ROOT_URL=https://192.168.99.100/
    - Accounts_UseDNSDomainCheck=True
    - ADMIN_USERNAME=admin
    - ADMIN_PASS=supersecret
    - ADMIN_EMAIL=admin@example.com
  links:
    - db:db
  ports:
    - 3000:3000

hubot:
  image: rocketchat/hubot-rocketchat:v1.0.6
  environment:
    - ROCKETCHAT_URL=192.168.99.100:3000
    - ROCKETCHAT_ROOM=GENERAL
    - ROCKETCHAT_USER=bot
    - ROCKETCHAT_PASSWORD=bot
    - LISTEN_ON_ALL_PUBLIC=true
    - BOT_NAME=hubot
    - EXTERNAL_SCRIPTS=hubot-help,hubot-seen,hubot-links,hubot-greetings,hubot-diagnostics,hubot-google,hubot-reddit,hubot-bofh,hubot-bookmark,hubot-shipit,hubot-maps
  links:
    - rocketchat:rocketchat
# this is used to expose the hubot port for notifications on the host on port 3001, e.g. for hubot-jenkins-notifier
  ports:
    - 3001:8080

Note: Replace the ROCKETCHAT_URL and ROOT_URL with IP address of your docker-machine docker host IP or use localhost.

Let’s run docker-compose:

docker-compose up
Creating hubotrocketchat_db_1
Creating hubotrocketchat_rocketchat_1
Creating hubotrocketchat_hubot_1
Attaching to hubotrocketchat_db_1, hubotrocketchat_rocketchat_1, hubotrocketchat_hubot_1
db_1          | about to fork child process, waiting until server is ready for connections.
db_1          | forked process: 15
rocketchat_1  | ➔ +------------------------------------------------+
rocketchat_1  | ➔ |                 SERVER RUNNING                 |
rocketchat_1  | ➔ +------------------------------------------------+
rocketchat_1  | ➔ |                                                |
rocketchat_1  | ➔ |  Rocket.Chat Version: 0.54.2                   |
rocketchat_1  | ➔ |       NodeJS Version: 4.8.1 -- x64              |
rocketchat_1  | ➔ |             Platform: linux                    |
rocketchat_1  | ➔ |         Process Port: 3000                     |
rocketchat_1  | ➔ |             Site URL: https://192.168.99.100/  |
rocketchat_1  | ➔ |     ReplicaSet OpLog: Disabled                 |
rocketchat_1  | ➔ |          Commit Hash: 13571b070e               |
rocketchat_1  | ➔ |        Commit Branch: HEAD                     |
rocketchat_1  | ➔ |                                                |
rocketchat_1  | ➔ +------------------------------------------------+
hubot_1       | [Tue Apr 04 2017 18:50:05 GMT+0000 (UTC)] INFO Starting Rocketchat adapter version 1.0.6…
hubot_1       | [Tue Apr 04 2017 18:50:05 GMT+0000 (UTC)] INFO Once connected to rooms I will respond to the name: >hubot
hubot_1       | [Tue Apr 04 2017 18:50:05 GMT+0000 (UTC)] INFO I will also respond to my Rocket.Chat username as an alias: bot
hubot_1       | [Tue Apr 04 2017 18:50:05 GMT+0000 (UTC)] INFO Connecting To: 192.168.99.100:3000
hubot_1       | [Tue Apr 04 2017 18:50:05 GMT+0000 (UTC)] INFO Successfully connected!
hubot_1       | [Tue Apr 04 2017 18:50:05 GMT+0000 (UTC)] INFO
hubot_1       | [Tue Apr 04 2017 18:50:05 GMT+0000 (UTC)] INFO Logging In

Let’s login on Rocket.Chat with our admin account credential we defined in our docker-compose.yml (admin/supersecret), for this point your browser to http://192.168.99.100:3000/

Once logged, click on Admin and select Administration/Users and add the bot user with the following:

  • Name: hubot
  • Username: bot
  • Email: bot@yourdomainname.com
  • Check Verified
  • Password: bot
  • Uncheck Require Password Change
  • Role: bot
  • Check: Join the main channel
  • Uncheck send the welcome message
  •  
    Click Save and Logout.

    Time to Register your user, on the login page of Rocket.Chat, select Register a new account, follow the information and login with your new user.

    In order to have Hubot communicate with Rocket.Chat, it must be able to login as the user bot, for this let’s stop our docker-composer by doing a CTRL-C and run again docker-compose up.

    Gracefully stopping… (press Ctrl+C again to force)
    Stopping hubotrocketchat_hubot_1 … done
    Stopping hubotrocketchat_rocketchat_1 … done
    Stopping hubotrocketchat_db_1 … done
    docker-compose up
    Starting hubotrocketchat_db_1
    Starting hubotrocketchat_rocketchat_1
    Starting hubotrocketchat_hubot_1
    Attaching to hubotrocketchat_db_1, hubotrocketchat_rocketchat_1, hubotrocketchat_hubot_1
    hubot_1       | [Tue Apr 04 2017 19:20:22 GMT+0000 (UTC)] INFO Starting Rocketchat adapter version 1.0.6…
    hubot_1       | [Tue Apr 04 2017 19:20:22 GMT+0000 (UTC)] INFO Once connected to rooms I will respond to the name: >hubot
    hubot_1       | [Tue Apr 04 2017 19:20:22 GMT+0000 (UTC)] INFO I will also respond to my Rocket.Chat username as an alias: bot
    hubot_1       | [Tue Apr 04 2017 19:20:22 GMT+0000 (UTC)] INFO Connecting To: 192.168.99.100:3000
    hubot_1       | [Tue Apr 04 2017 19:20:22 GMT+0000 (UTC)] INFO Successfully connected!
    hubot_1       | [Tue Apr 04 2017 19:20:22 GMT+0000 (UTC)] INFO
    hubot_1       | [Tue Apr 04 2017 19:20:22 GMT+0000 (UTC)] INFO Logging In
    hubot_1       | [Tue Apr 04 2017 19:30:51 GMT+0000 (UTC)] INFO rid:  []
    hubot_1       | [Tue Apr 04 2017 19:30:51 GMT+0000 (UTC)] INFO All rooms joined.
    hubot_1       | [Tue Apr 04 2017 19:30:51 GMT+0000 (UTC)] INFO Preparing Meteor Subscriptions..
    hubot_1       | [Tue Apr 04 2017 19:30:51 GMT+0000 (UTC)] INFO Subscribing to Room: __my_messages__
    hubot_1       | [Tue Apr 04 2017 19:30:51 GMT+0000 (UTC)] INFO Successfully subscribed to messages
    hubot_1       | [Tue Apr 04 2017 19:30:51 GMT+0000 (UTC)] INFO Setting up reactive message list…

    You can now communicate with the hubot chat bot, i.e. @hubot help

    You can find new script at GitHub Hubot Scripts.

    Just add them in your docker-compose.yml:

    - EXTERNAL_SCRIPTS=hubot-help,hubot-seen,hubot-links,hubot-greetings,hubot-diagnostics,hubot-google,hubot-reddit,hubot-bofh,hubot-bookmark,hubot-shipit,hubot-maps,hubot-thesimpsons
    

    Continuous S.A.
    Avenue des Hauts-Fourneaux 9
    L-4362 Esch-sur-Alzette
    Luxembourg

    © Continuous S.A. 2017