skfbot is a chat bot built on the [Hubot][hubot] framework. It was initially generated by [generator-hubot][generator-hubot], and configured to be deployed on [Heroku][heroku] to get you up and running as quick as possible.
You can check this bot on gitter.im in the following lobbies:
Security-Knowledge-Framework/Lobby
To get hubot, or in our case skfbot running, these are the steps that had to be followed. I have captured them here so that we don't forget what was done 😸
NOTE: Although there are two hubot adapter's for Gitter, we found that only one of them works. Namely, this one. The other one seems older, and has been replaced by the one that we ended up using.
-
Login into Gitter with the Github account that you want to run as your bot(Probably make a new github account which have only one repo which is your bot)
-
Join the room that you want the bot to be activated on (i.e. Security-Knowledge-Framework/Lobby)
-
Install node.js (which includes npm)
-
Install Heroku Toolkit (In case of Ubuntu * 'sudo snap install heroku --classic') for other refer this
-
mkdir skfbot
-
cd skfbot
-
heroku login
-
npm install --global coffee-script hubot
-
npm install --global yo generator-hubot
-
yo hubot
(when prompted, entergitter2
as adapter name, andskfbot
as name -
npm install --save hubot-gitter2
-
git init
-
git add .
-
git commit -m "Initial commit"
-
heroku create
-
heroku config:set HUBOT_GITTER2_TOKEN=****
(here the token is the Personal Access Token for Github Account that will be running as the bot, in our case, the skf-bot user on Github. The Personal Access Token can be retrieved from here -
heroku config:set HEROKU_URL=https://whispering-peak-2284.herokuapp.com/
(this is to keep the heroku application alive. The URL is generated from theheroku create
command above -
heroku config:set HUBOT_GITTER2_TESTING_ROOMS=Security-Knowledge-Framework/Lobby
(this was used initially to verify that it was working on one room in particular, but it was later removed so that any room that skfbot user is signed into will respond to commands) -
heroku config:set HUBOT_ADAPTER="gitter2"
(this ensures we use the gitter2 adapter) -
heroku addons:create scheduler:standard
(this adds the free heroku scheduler to your account) -
Sign into your heroku account, and click on the newly created scheduler
-
Edit the settings of the job to look like the following: NOTE: The next due time you be set as the same as the
HUBOT_HEROKU_WAKEUP_TIME
above. -
git push heroku master
-
heroku logs
(if all goes well here, you should see something simalar to the following)
If all of the above has worked, go to your Gitter Chat Room, and try issuing a hubot command like @skfbot ping
and hopefully you will see the following:
You can test your hubot by running the following locally.
You can clone this repo in your system and then cd skfbot
After that you can start skfbot locally by running:
$ ./bin/hubot
You'll see some start up output and a prompt:
[Sat Feb 28 2015 12:38:27 GMT+0000 (GMT)] INFO Using default redis on localhost:6379
skfbot>
Then you can interact with skfbot by typing skfbot help
.
skfbot> skfbot help
skfbot animate me <query> - The same thing as `image me`, except adds [snip]
skfbot help - Displays all of the help commands that skfbot knows about.
...
An example script is included at scripts/example.coffee
, so check it out to
get started, along with the Scripting Guide.
For many common tasks, there's a good chance someone has already one to do just the thing.
There will inevitably be functionality that everyone will want. Instead of writing it yourself, you can check hubot-scripts for existing scripts.
To enable scripts from the hubot-scripts package, add the script name with
extension as a double quoted string to the hubot-scripts.json
file in this
repo.
Hubot is able to load scripts from third-party npm
package. Check the package's documentation, but in general it is:
- Add the packages as dependencies into your
package.json
npm install
to make sure those packages are installed- Add the package name to
external-scripts.json
as a double quoted string
You can review external-scripts.json
to see what is included by default.
Adapters are the interface to the service you want your hubot to run on. This can be something like Campfire or IRC. There are a number of third party adapters that the community have contributed. Check Hubot Adapters for the available ones.
If you would like to run a non-Campfire or shell adapter you will need to add
the adapter package as a dependency to the package.json
file in the
dependencies
section.
Once you've added the dependency and run npm install
to install it you can
then run hubot with the adapter.
% bin/hubot -a <adapter>
Where <adapter>
is the name of your adapter without the hubot-
prefix.
% heroku create --stack cedar
% git push heroku master
If your Heroku account has been verified you can run the following to enable and add the Redis to Go addon to your app.
% heroku addons:add redistogo:nano
If you run into any problems, checkout Heroku's docs.
You'll need to edit the Procfile
to set the name of your hubot.
More detailed documentation can be found on the deploying hubot onto Heroku wiki page.
If you would like to deploy to either a UNIX operating system or Windows. Please check out the deploying hubot onto UNIX and deploying hubot onto Windows wiki pages.
robot.hear /@skfchatbot (.*)/i, (res)->
After this it will only listens to its name
More details in Script folder
You may want to get comfortable with heroku logs
and heroku restart
if you're having issues.