Individual bots can be set up manually by the process described below:
- Clone our OnBot repository from github (git clone https://github.com/CognizantOneDevOps/OnBot.git)
- Copy the desired bot scripts from the scripts folder of the cloned repo
- Run this command: npm install -g yo generator-hubot
- Create a parent folder myhubot
- Run the following commands:
cd myhubot
yo hubot
- Copy the scripts from the cloned repository (first step) into myhubot/scripts folder
yo generator creates the package.json file under myhubot directory
Download the workflow_botname.json attached with the respective bots below, then rename it as workflow.json and place into the myhubot directory
- Run: npm install
- Now set the required environment variables (As mentioned below in Environment Variables for specific bots section)
Finally, start the bot as a background process (logs will be redirected to hubot.log file): nohup ./bin/hubot -a slack > hubot.log &
Before starting the bot, Run npm install hubot-<adapter> to install specific node module for the adapter (chat application) you want to use.
At any time the bot running in background can be stopped by this command: ps aux | grep -ie <botname> | awk '{print $2}' | xargs kill -9
The <botname> can be fetched from the following line of the bin/hubot file:
exec node_modules/.bin/hubot --name "botname" "$@"
EXPRESS_PORT (Port number where the hubot will run)
MY_POD_IP (Host address where bot is running)
MONITOR_INTERVAL (Time Interval for monitoring bot)
MONITOR_RETENSION (mapped to 1 (stores a jsonobj in elasticsearch which has all hubot metrics of a current second))
MONGO_DB_URL (mongodb database name for approval process of bot actions)
MONGO_COLL (mongodb collection name for approval process of bot actions)
MONGO_COUNTER (mongodb collection name for storing the number of next ticket to be generated)
MONGO_TICKETIDGEN (stores the Id of the collection referred by MONGO_COUNTER)
APPROVAL_APP_URL (middleware application endpoint which will handle approval flow in mattermost)
MONGO_DB_NAME (The database name which has MONGO_COLL and MONGO_COUNTER in it)
ELASTIC_SEARCH_IP (elasticsearch ip address)
ELASTIC_SEARCH_PORT (elasticsearch port)
HUBOT_SLACK_TOKEN (API token for connecting with slack)
MATTERMOST_ENDPOINT (context of the endpoint where bot is running with mattermost adapter)
MATTERMOST_INCOME_URL (Mattermost Incoming webhook)
MATTERMOST_TOKEN (Mattermost outgoing token - to be configured with outgoing webhook)
To implement the approval flow with the bot, whichever collection name you put in MONGO_COUNTER variable(mentioned above) should be present inside the db set by MONGO_DB_NAME.
For example- suppose you have MONGO_COUNTER=counters and MONGO_DB_NAME=hubot set in your environment. Then you should have a database called "hubot" inside your mongodb. This "hubot" should contain a collection named "counters" having this structure: { _id: "ticketIdGenerator",seq: 100}
To create a collection like this, go to your mongo shell and execute below steps:
- use hubot
- db.createCollection("counters")
- db.counters.insert({_id: "ticketIdGenerator",seq: 100})
The MONGO_TICKETIDGEN should contain the Id of the collection referred by MONGO_COUNTER. Therefore, for the above example, MONGO_TICKETIDGEN=ticketIdGenerator.
0 Comments