SlideShare a Scribd company logo
Hubot scripting in Slack
Juneyoung Oh
I-ON Communications
2015.08.01
Index of Contents
Purpose of this Presentation
Install Hubot on OSX
Invite Hubot in Slack room
Writing custom script for Hubot (js)
Tips from personal experiences
CAUTION : I will do all this on OSX with Slack, Heroku.
Purpose of this presentation
This presentation for you :
- Want to make fun bot in your slack community
- Who knows little about javascript
- Want to try something fun with js, but do not want to much time
on it
This presentation NOT for you :
- Hardcore programmer who ought know everything running in
background
- Who never heard of javascript (I am not going to talk about js basic
:<)
- Want to write custom script for Hubot in coffee script. (There are
many examples for coffee on web, so go for it :D)
Installing Hubot on OSX
CAUTION : Things NOT going to mention in here, but you need to prepare for
further steps.
- Install node.js on your system
- Install nvm (node version mananger) on your system
Official Hubot installation guide can be found here :
https://hubot.github.com/docs/
This link could be more accurate but I am going to talk about errors I have met while following those
steps.
Installing Hubot on OSX
First, Install `hubot-generator` with `yo`.
Could get following errors. it just need some authority on your system.
Fix this with `sudo` command like :
Installing Hubot on OSX
Now, make a directory for the bot
Move into project directory
Calling hubot!
You could see following on your screen
Installing Hubot on OSX
In Terminal, you should fill some fields to proceed.
[ Fields list ]
- Owner : Bot Owner name, nothing special.
- Bot name : Going to use this name to call this bot. i.e. If your bot name is
‘testbot’, than `testbot what is your name?`
- Description : Nothing special.
- Adapter : Adapters which could use this bot. default is ‘campfire’. However,
you can change this anytime by editing a file named ‘Procfile’
This are sample which I wrote for this
presentation :D
Installing Hubot on OSX
Now, talk about directories & Files.
Can check with `ls` command. It should shows like follow :D
[File List]
- Procfile : can edit ‘Adapter’ options here.
- external-scripts.js : Additional hubot script. User Custom Script Name can be
found here.
- READ.md : This file for git. If you using a service like ‘github’, This document
will be shows at first.
- hubot-scripts.json : Additional hubot script. But these are specific. Details
could be found : https://www.npmjs.com/browse/keyword/hubot-scripts
- scripts(d) : Put your custom script this directory. To use this script, you have to
specify the name on external-script.js
- bin(d) : A directory which has hubot execution file.
Installing Hubot on OSX
Let’s run this :D
For now, a prompt is all. However still hubot can do serveral commands.
Type following command.
remember, this space for your ‘Botname’.
Simple command sample for you.
Now, Let’s connect this with Slack!
Invite Hubot in Slack room
Let’s make this bot work in slack :D
Before start …
- I assume that you already have a slack account
- I assume that you already install heroku tool-belt.
- Official tutorial can be found : https://github.com/slackhq/hubot-slack
1. Let the bot knows our adapter is ‘slack’.
Go to hubot project folder, and open this with `vi` command.
It looks like this.
We need to edit this file. so press ‘a’ or ‘I’ key to switch to ‘insert mode’. check
the left bottom of terminal and you will see…
Invite Hubot in Slack room
2. Replace that line with follow.
If you want to keep the original one, add ‘#’ to the front of the line, so computer
consider that as a comment, not a command.
Than, press ‘esc’ key to manage mode and type ‘:wq’.
‘w’ means ‘write’ and ‘q’ means ‘quit’.
TIPS. In normal mode type ‘:set nu’. now, vi shows line number for you. This
function is quite useful when handling long script.
Invite Hubot in Slack room
3. Deploy this to Heroku.
For further information for Heroku, visit the link : http://www.heroku.com
You will get following as result.
As you can see in the last line, Heroku internally uses git.
So our further jobs should upload and synchronized with that git URL.
In this case,
https://git.heroku.com/testbotapp.git is my heroku git address.
Invite Hubot in Slack room
4. Install Heroku redistogo addon.
Hubot uses redis DB as its brain, so need to install this to Heroku.(do not need to
install redis on your local.)
heroku addons:create (addon name) –app (your app name in Heroku)
green : Heroku command.
orange : variables
purple : which could be skipped (If you have bunch of Heroku apps like me, need
to point specific target application)
* You need to register ACCOUNT INFORMATION to use heroku addons, even
though it is free. It is necessary.
Invite Hubot in Slack room
5-1. Add configurations to Heroku.
To service Slack, it needs to know HEROKU URL and HEROKU_SLACK_TOKEN.
Let’s add.
Go to below URL:
https://{your room}.slack.com/services/new/hubot
After input your bot’s name, get TOKEN from the page.(It is on the top of the
page. Can not be missed)
Invite Hubot in Slack room
5-2. Add configurations to Heroku.
Add information from the Terminal.
HEROKU_URL can be found heroku.com page.
In [Setting] tab, middle of the page [info] section.
Invite Hubot in Slack room
6. Run your bot and meet it in your Slack.
First, need to push our code to heroku. Than, run it!
If you already have other heroku app, need to some extra process.
Move to top folder of your Project. Than type follow before push.
Now run our bot.
As a result, can find bot in slack. See [DIRECT MESSAGES] section.
Writing custom bot script (js)
This pages for custom hubot scripting for javascript, NOT coffee script.
Basic : Write custom script under ‘scripts’ folder .
Writing custom bot script (js)
After, writing script. Edit ‘hubot-scripts.json’ in top folder.
Add your script name without extension.
Left side is my folder structure, and right is contents of hubot-scripts.json.
Writing custom bot script (js)
Finally, use ‘add’, ‘commit’ and ‘push’ command.
Than, ‘heroku open’.
And go to slack, what you can see …
Tips from personal exp
Tips from my experiences.
1. Checking heroku logs.
This will be quite useful, since there are no scripting guides for javascript. By
doing this, can find more information about internal object like message, robot or
adapter.
2. Could not use DOM Elements.
Hubot script can not use ‘document’ Object. (XMLHttpRequest Object also could
not found).
Tips from personal exp
Tips from my experiences.
3. Use ajax with internal API.
For instance, it looks like…
4. In slack, some of APIs are forbidden to bot.
i.e. kick API can not be called by a bot. For more information, refer following
URL : https://api.slack.com/methods
Tips from personal exp
Tips from my experiences.
5. Refer coffee script codes.
There are no documents for javascript. So if you use js, you have to look what
original structure(coffee) is. Refer ‘src’ directory of hubot github.
URL : https://github.com/github/hubot/tree/master/src
Just like coffee, some objects will be found in js version.
i.e. message, brain, robot, user … Can check if you print those in console and read
heroku logs.
Thanks!

More Related Content

PDF
Chat bot-automation-hubot
PDF
Hubot: a look inside our robot friend
PDF
Shared Object images in Docker: What you need is what you want.
PDF
Google apps script introduction
PDF
The Puppet Debugging Kit: Building Blocks for Exploration and Problem Solving...
PDF
Screenshot as a service
ODP
Automated reproducible images on openstack using vagrant and packer
ODP
Writing webapps with Perl Dancer
Chat bot-automation-hubot
Hubot: a look inside our robot friend
Shared Object images in Docker: What you need is what you want.
Google apps script introduction
The Puppet Debugging Kit: Building Blocks for Exploration and Problem Solving...
Screenshot as a service
Automated reproducible images on openstack using vagrant and packer
Writing webapps with Perl Dancer

What's hot (20)

PDF
Py conkr 20150829_docker-python
PDF
Gael Le Mignot How To Minimize Cpu And Memory Usage Of Zope And Plone Appli...
PDF
Aucklug slides - desktop tips and tricks
PDF
Perl Dancer for Python programmers
PPTX
Ultimate Unix Meetup Presentation
ODP
An introduction to Rex - FLOSS UK DevOps York 2015
PDF
Fullstack Academy - Awesome Web Dev Tips & Tricks
PPT
Riki Fridrich - Grunt, Gulp a spol. - Automatizáciou k maximalizácii lenivosti
PDF
CoffeeScript in 5mins
PPTX
Sphinx autodoc - automated api documentation - PyCon.KR 2015
PDF
Terminus, the Pantheon command-line interface
PPTX
2012 coscup - Build your PHP application on Heroku
PDF
PerlDancer for Perlers (FOSDEM 2011)
PDF
Docker, c'est bonheur !
PDF
Go初心者がGoでコマンドラインツールの作成に挑戦した話
PPTX
How did puppet change our system's life?
PDF
[H3 2012] 우리가 모르는 Node.js로 할 수 있는 몇가지
ODP
Tame your Infrastructure with Puppet
ODP
Perl Dancer, FPW 2010
PDF
Making environment for_infrastructure_as_code
Py conkr 20150829_docker-python
Gael Le Mignot How To Minimize Cpu And Memory Usage Of Zope And Plone Appli...
Aucklug slides - desktop tips and tricks
Perl Dancer for Python programmers
Ultimate Unix Meetup Presentation
An introduction to Rex - FLOSS UK DevOps York 2015
Fullstack Academy - Awesome Web Dev Tips & Tricks
Riki Fridrich - Grunt, Gulp a spol. - Automatizáciou k maximalizácii lenivosti
CoffeeScript in 5mins
Sphinx autodoc - automated api documentation - PyCon.KR 2015
Terminus, the Pantheon command-line interface
2012 coscup - Build your PHP application on Heroku
PerlDancer for Perlers (FOSDEM 2011)
Docker, c'est bonheur !
Go初心者がGoでコマンドラインツールの作成に挑戦した話
How did puppet change our system's life?
[H3 2012] 우리가 모르는 Node.js로 할 수 있는 몇가지
Tame your Infrastructure with Puppet
Perl Dancer, FPW 2010
Making environment for_infrastructure_as_code
Ad

Viewers also liked (20)

PDF
Create Your Own Chatbot with Hubot and CoffeeScript
PPTX
ChatOps meetup: les humains parlent aux robots
PDF
도커의 기초 - 김상필 솔루션즈 아키텍트 :: AWS Container Day
PDF
When Splunk meets Slack
PDF
Let's talk ChatOps - Hubot with less CoffeeScript
PDF
Introduction to hubot
PDF
Embrace chatops, stop installing deployment software - Laracon EU 2016
PDF
PDF
ChatOps with Hubot
PDF
Chat ops .. a beginner's guide
PPTX
aws/docker/rails를 활용한 시스템 구축/운용 - docker편
PDF
Gaming on AWS - 6. AWS 환경에서의 유연하고 신속한 코드 관리 및 배포
PDF
今日から始める人工知能 × 機械学習 Meetup ライトニングトーク1
PDF
Landset 8 的雲層去除技巧實作
PDF
小魯蛇與他快樂的夥伴
PDF
合同勉強会20160821
PDF
AWS를 활용한 첫 빅데이터 프로젝트 시작하기(김일호)- AWS 웨비나 시리즈 2015
PDF
20150419_pbtech_openstack_nyah #pbtech
PDF
LINE Bot 作ってみた
PDF
ChatOps@研究室
Create Your Own Chatbot with Hubot and CoffeeScript
ChatOps meetup: les humains parlent aux robots
도커의 기초 - 김상필 솔루션즈 아키텍트 :: AWS Container Day
When Splunk meets Slack
Let's talk ChatOps - Hubot with less CoffeeScript
Introduction to hubot
Embrace chatops, stop installing deployment software - Laracon EU 2016
ChatOps with Hubot
Chat ops .. a beginner's guide
aws/docker/rails를 활용한 시스템 구축/운용 - docker편
Gaming on AWS - 6. AWS 환경에서의 유연하고 신속한 코드 관리 및 배포
今日から始める人工知能 × 機械学習 Meetup ライトニングトーク1
Landset 8 的雲層去除技巧實作
小魯蛇與他快樂的夥伴
合同勉強会20160821
AWS를 활용한 첫 빅데이터 프로젝트 시작하기(김일호)- AWS 웨비나 시리즈 2015
20150419_pbtech_openstack_nyah #pbtech
LINE Bot 作ってみた
ChatOps@研究室
Ad

Similar to How to build a slack-hubot with js (20)

PPTX
Hubot
PDF
Host Line Bot with Golang
PDF
Chat Bots and how to build a Slack bot
PDF
Writing a slack chatbot seattle
PDF
Building a Slack Bot Workshop @ Nearsoft OctoberTalks 2017
PDF
Building Enterprise Chat Bots
PDF
Writing a slack chatbot mxlos
PDF
chatops-presentation
PDF
Identifying and solving enterprise problems
PDF
Building a slackbot
PDF
Writing a slack chatbot DrupalCampLA
PDF
Teaming up with robot!
PPTX
How to build a slack bot
PPTX
Automating web application security testing using Hubot AI / NLP chat bot - B...
PDF
An introduction to Hubot - CloudConf 2015 - Turin Italy
PDF
Modern Web 2016: Using Golang to build a smart IM Bot
PDF
Build apps for slack
PDF
Introduction to Chatbot Development for Facebook Messenger using Python
PPTX
Building Chatbots
PPTX
Hubot and Playbook - Oct 2016 ChatbotsAU meetup
Hubot
Host Line Bot with Golang
Chat Bots and how to build a Slack bot
Writing a slack chatbot seattle
Building a Slack Bot Workshop @ Nearsoft OctoberTalks 2017
Building Enterprise Chat Bots
Writing a slack chatbot mxlos
chatops-presentation
Identifying and solving enterprise problems
Building a slackbot
Writing a slack chatbot DrupalCampLA
Teaming up with robot!
How to build a slack bot
Automating web application security testing using Hubot AI / NLP chat bot - B...
An introduction to Hubot - CloudConf 2015 - Turin Italy
Modern Web 2016: Using Golang to build a smart IM Bot
Build apps for slack
Introduction to Chatbot Development for Facebook Messenger using Python
Building Chatbots
Hubot and Playbook - Oct 2016 ChatbotsAU meetup

More from Juneyoung Oh (7)

PPTX
Docker introduction for the beginners
PPTX
Docker 사내교육 자료
PPTX
휴봇-슬랙 OSX 설치
DOCX
Github 의 release 기능
PPTX
Html5 canvas6 week6n7n8
PPTX
Html5 canvas study week1n2
PPTX
Tizen installation guide for OSX
Docker introduction for the beginners
Docker 사내교육 자료
휴봇-슬랙 OSX 설치
Github 의 release 기능
Html5 canvas6 week6n7n8
Html5 canvas study week1n2
Tizen installation guide for OSX

Recently uploaded (20)

PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPTX
OOP with Java - Java Introduction (Basics)
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
Geodesy 1.pptx...............................................
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
Welding lecture in detail for understanding
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPTX
Lecture Notes Electrical Wiring System Components
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PDF
PPT on Performance Review to get promotions
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
UNIT 4 Total Quality Management .pptx
PPT
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
OOP with Java - Java Introduction (Basics)
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Operating System & Kernel Study Guide-1 - converted.pdf
bas. eng. economics group 4 presentation 1.pptx
Geodesy 1.pptx...............................................
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Internet of Things (IOT) - A guide to understanding
Welding lecture in detail for understanding
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
Lecture Notes Electrical Wiring System Components
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPT on Performance Review to get promotions
CH1 Production IntroductoryConcepts.pptx
UNIT 4 Total Quality Management .pptx
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS

How to build a slack-hubot with js

  • 1. Hubot scripting in Slack Juneyoung Oh I-ON Communications 2015.08.01
  • 2. Index of Contents Purpose of this Presentation Install Hubot on OSX Invite Hubot in Slack room Writing custom script for Hubot (js) Tips from personal experiences CAUTION : I will do all this on OSX with Slack, Heroku.
  • 3. Purpose of this presentation This presentation for you : - Want to make fun bot in your slack community - Who knows little about javascript - Want to try something fun with js, but do not want to much time on it This presentation NOT for you : - Hardcore programmer who ought know everything running in background - Who never heard of javascript (I am not going to talk about js basic :<) - Want to write custom script for Hubot in coffee script. (There are many examples for coffee on web, so go for it :D)
  • 4. Installing Hubot on OSX CAUTION : Things NOT going to mention in here, but you need to prepare for further steps. - Install node.js on your system - Install nvm (node version mananger) on your system Official Hubot installation guide can be found here : https://hubot.github.com/docs/ This link could be more accurate but I am going to talk about errors I have met while following those steps.
  • 5. Installing Hubot on OSX First, Install `hubot-generator` with `yo`. Could get following errors. it just need some authority on your system. Fix this with `sudo` command like :
  • 6. Installing Hubot on OSX Now, make a directory for the bot Move into project directory Calling hubot! You could see following on your screen
  • 7. Installing Hubot on OSX In Terminal, you should fill some fields to proceed. [ Fields list ] - Owner : Bot Owner name, nothing special. - Bot name : Going to use this name to call this bot. i.e. If your bot name is ‘testbot’, than `testbot what is your name?` - Description : Nothing special. - Adapter : Adapters which could use this bot. default is ‘campfire’. However, you can change this anytime by editing a file named ‘Procfile’ This are sample which I wrote for this presentation :D
  • 8. Installing Hubot on OSX Now, talk about directories & Files. Can check with `ls` command. It should shows like follow :D [File List] - Procfile : can edit ‘Adapter’ options here. - external-scripts.js : Additional hubot script. User Custom Script Name can be found here. - READ.md : This file for git. If you using a service like ‘github’, This document will be shows at first. - hubot-scripts.json : Additional hubot script. But these are specific. Details could be found : https://www.npmjs.com/browse/keyword/hubot-scripts - scripts(d) : Put your custom script this directory. To use this script, you have to specify the name on external-script.js - bin(d) : A directory which has hubot execution file.
  • 9. Installing Hubot on OSX Let’s run this :D For now, a prompt is all. However still hubot can do serveral commands. Type following command. remember, this space for your ‘Botname’. Simple command sample for you. Now, Let’s connect this with Slack!
  • 10. Invite Hubot in Slack room Let’s make this bot work in slack :D Before start … - I assume that you already have a slack account - I assume that you already install heroku tool-belt. - Official tutorial can be found : https://github.com/slackhq/hubot-slack 1. Let the bot knows our adapter is ‘slack’. Go to hubot project folder, and open this with `vi` command. It looks like this. We need to edit this file. so press ‘a’ or ‘I’ key to switch to ‘insert mode’. check the left bottom of terminal and you will see…
  • 11. Invite Hubot in Slack room 2. Replace that line with follow. If you want to keep the original one, add ‘#’ to the front of the line, so computer consider that as a comment, not a command. Than, press ‘esc’ key to manage mode and type ‘:wq’. ‘w’ means ‘write’ and ‘q’ means ‘quit’. TIPS. In normal mode type ‘:set nu’. now, vi shows line number for you. This function is quite useful when handling long script.
  • 12. Invite Hubot in Slack room 3. Deploy this to Heroku. For further information for Heroku, visit the link : http://www.heroku.com You will get following as result. As you can see in the last line, Heroku internally uses git. So our further jobs should upload and synchronized with that git URL. In this case, https://git.heroku.com/testbotapp.git is my heroku git address.
  • 13. Invite Hubot in Slack room 4. Install Heroku redistogo addon. Hubot uses redis DB as its brain, so need to install this to Heroku.(do not need to install redis on your local.) heroku addons:create (addon name) –app (your app name in Heroku) green : Heroku command. orange : variables purple : which could be skipped (If you have bunch of Heroku apps like me, need to point specific target application) * You need to register ACCOUNT INFORMATION to use heroku addons, even though it is free. It is necessary.
  • 14. Invite Hubot in Slack room 5-1. Add configurations to Heroku. To service Slack, it needs to know HEROKU URL and HEROKU_SLACK_TOKEN. Let’s add. Go to below URL: https://{your room}.slack.com/services/new/hubot After input your bot’s name, get TOKEN from the page.(It is on the top of the page. Can not be missed)
  • 15. Invite Hubot in Slack room 5-2. Add configurations to Heroku. Add information from the Terminal. HEROKU_URL can be found heroku.com page. In [Setting] tab, middle of the page [info] section.
  • 16. Invite Hubot in Slack room 6. Run your bot and meet it in your Slack. First, need to push our code to heroku. Than, run it! If you already have other heroku app, need to some extra process. Move to top folder of your Project. Than type follow before push. Now run our bot. As a result, can find bot in slack. See [DIRECT MESSAGES] section.
  • 17. Writing custom bot script (js) This pages for custom hubot scripting for javascript, NOT coffee script. Basic : Write custom script under ‘scripts’ folder .
  • 18. Writing custom bot script (js) After, writing script. Edit ‘hubot-scripts.json’ in top folder. Add your script name without extension. Left side is my folder structure, and right is contents of hubot-scripts.json.
  • 19. Writing custom bot script (js) Finally, use ‘add’, ‘commit’ and ‘push’ command. Than, ‘heroku open’. And go to slack, what you can see …
  • 20. Tips from personal exp Tips from my experiences. 1. Checking heroku logs. This will be quite useful, since there are no scripting guides for javascript. By doing this, can find more information about internal object like message, robot or adapter. 2. Could not use DOM Elements. Hubot script can not use ‘document’ Object. (XMLHttpRequest Object also could not found).
  • 21. Tips from personal exp Tips from my experiences. 3. Use ajax with internal API. For instance, it looks like… 4. In slack, some of APIs are forbidden to bot. i.e. kick API can not be called by a bot. For more information, refer following URL : https://api.slack.com/methods
  • 22. Tips from personal exp Tips from my experiences. 5. Refer coffee script codes. There are no documents for javascript. So if you use js, you have to look what original structure(coffee) is. Refer ‘src’ directory of hubot github. URL : https://github.com/github/hubot/tree/master/src Just like coffee, some objects will be found in js version. i.e. message, brain, robot, user … Can check if you print those in console and read heroku logs.