Running a Hubot bot
Developers should start with (or at least reference) our example Hubot demonstrating usage of the pimentaCHAT adaptor: hubot-pimentachat-boilerplate
See GitHub’s own documentation for examples on building and scripting your bot.
There is also a Yeoman generator for Hubot projects, that can generate a bot using the pimentaCHAT adapter, however it does use the latest versions of Hubot or our adapter module, which enable asynchronous processing in ES6 Javascript, along with various bug fixes.
In all cases you first need to configure the environment
Deployment examples below use either the boilerplate or a Docker instance.
Once the bot is running and is properly logged in and connected to your RC server/configured channels, you can test by logging in as a regular user (not the BOT user), go to a configured channel and start talking to your bot (you’ll find some pre-configured dialogs below).
Using the Boilerplate
Please see our boilerplate bot Getting Started docs here!
The boilerplate is essentially just a simple Node.js package that requires
Hubot and the pimentaCHAT adapter. The bot can then be executed using a bin file
in production, as seen here.
Or via the package scripts locally using npm run local
or yarn local
Using the boilerplate example, to start the bot in production, use
bin/hubot -a pimentachat
- will install dependencies and run the bot with
pimentaCHAT’s Hubot adapter.
More info in Hubot’s own docs here
Quick Start
Create and run a pimentaCHAT bot in under two minutes.
git clone https://bitbucket.org/pimenta-group/hubot-pimentachat-boilerplate/
cd hubot-pimentachat-boilerplate
npm install
Create a .env file with content:
export PIMENTACHAT_URL=myserver.com
export PIMENTACHAT_USER=mybotuser
export PIMENTACHAT_PASSWORD=mypassword
export PIMENTACHAT_ROOM=general
export PIMENTACHAT_USE_SSL=true
Adjust the content to fit your server and user credentials. Make sure mybotuser
has BOT role on the server, if you don’t know what that means,
click here.
Then run the bot:
source .env
bin/hubot
On the server, login as a regular user (not the BOT user), go to GENERAL,
and try: mybotuser what is the time
OR mybotuser rc version
You can examine the source code of these two interactions under the /scripts
directory, where you can add your own bot scripts written in Javascript.
Using Docker
First clone the source and then move into the directory.
git clone: https://bitbucket.org/pimenta-group/hubot-pimentachat-boilerplate/
cd hubot-pimentachat
Now we start the docker container.
docker run -it -e PIMENTACHAT_URL=<your pimentachat instance>:<port> \
-e PIMENTACHAT_ROOM='' \
-e LISTEN_ON_ALL_PUBLIC=true \
-e PIMENTACHAT_USER=mybotuser \
-e PIMENTACHAT_PASSWORD=mypassword \
-e HUBOT_NAME=bot \
-e EXTERNAL_SCRIPTS=hubot-help,hubot-diagnostic \
-v $PWD:/home/hubot/node_modules/hubot-pimentachat pimentachat/hubot-pimentachat
On the server, login as a regular user (not the BOT user), go to GENERAL, and try:
mybotuser what is the time
Important notes
- The first time you run the docker container, the image needs to be pulled from the public docker registry and it will take some time. Subsequent runs are super fast.
- If you are not running Linux (i.e. if you are on a Mac or PC), you cannot use $PWD to mount the volumes. Instead, read this note here (the 2nd note on the page: If you are using Boot2Docker…) to determine the absolute path where you must place the git-cloned directory.