Create and run a Rocket.Chat bot in under two minutes.
NB: THIS IS A WORK IN PROGRESS
Please do not attempt to implement until this message is removed
-developtag will also be removed from the package file.
git clone https://github.com/RocketChat/hubot-rocketchat-boilerplate cd hubot-rocketchat-boilerplate npm install
Create a .env file with content:
export ROCKETCHAT_URL=myserver.com export ROCKETCHAT_USER=mybotuser export ROCKETCHAT_PASSWORD=mypassword export ROCKETCHAT_ROOM=general export ROCKETCHAT_USESSL=true
Adjust the content to fit your server and user credentials. Make sure
myuser has BOT role on the server, if you don't know what that means, ask your server administrator to set it up for you.
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 time is it
mybotuser rc version
< TBD: insert sample run screenshot >
You can examine the source code of these two bots under the
hubot-rocketchat prior to v2 are incompatible with Hubot v3
This bot is written in es6 and intended to run on node v8+. To run a bot on older versions of node would require compiling with babel to use the full es6 feature set.
Older versions of the adaptor (v0.*) are also incompatible with more recent versions of Rocket.Chat (v0.35+). Please report an issue if you find specific version mismatches and we'll update this document.
This is a boilerplate for making your own bots with Hubot and Rocket.Chat.
You can run with the shell adapter just to test
npm installto install dependencies
- Use the
yarn shellscript to start the bot with shell adaptor
hubot helpto see what it can do
When you're ready to connect the bot to an instance of Rocket.Chat
- Create a user for the bot, with the role bot
- Create an
./.envfile with the user and connection settings
yarn localscript to connect to your local Rocket.Chat
local npm script will read in the env file, so you can populate and modify
those settings easily (see configuration). In production, they
should be pre-populated in the server environment.
Running in Production
There are executables for different environments that all run the Hubot binary.
Before running make sure your production environment has the required
environment variables for the adapter, url, user, name and pass. Or you can add
them after the launch command as switches, like
Env variables should be populated on the server before launching (see configuration). The launcher will also install npm dependencies on every run, in case it's booting in a fresh container (this isn't required when working locally).
More information on deployment configs here.
Scripts can be added to the
./scripts folder, or by installing node packages
and listing their names in the
external-scripts.json array. There's an example
of each in this repo, but neither is required.
Two scripts are packaged with the boilerplate, as a demo for manual tests. Each of the following will respond in a public channel if the bot username is prefixed, or without the bot's name if in a DM.
what time is itor
what's the time- Tells you the time
rc version- Gives you version info for Rocket.Chat and Hubot (two messages)
When running locally, we've used
dotenv to load configs from the
./.env file. That makes it easy for setting environment variables.