Giter Site home page Giter Site logo

hubot-rocketchat's Introduction

Rocket.Chat logo

Rocket.Chat Test Coverage Code Climate MIT License

hubot-rocketchat

Hubot adapter for Rocket.Chat!

Feel free to join us in the #hubot channel to discuss hubot, and any scripts you might be working on.

Important

BREAKING CHANGES: v2.x.x contains major breaking changes. Starting with this version:

  • CoffeeScript BOTs will no longer be supported, all new bot scripts should be written in NodeJS 8 compatible JavaScript
  • Only Hubot v3 will be supported
  • you should only use Rocket.Chat Server version 0.63.0 or higher
  • Yeoman generator support is discontinued, you should start your project with our hubot v3 boilerplate
  • NodeJS 8 or later is required for operations
  • The latest ES6 syntax in NodeJS 8, including the popular async-await, is fully supported

v1.x.x versions of the adapter is only compatible with 0.37.1 and higher of Rocket.Chat Server. Yes, you should be able to continue using v1.x.x adapter and CoffeeScript bots with the most up-to-date version of the server.

If you are using Rocket.Chat 0.35.0 or earlier, please use v0.1.4 of the adapter. (releases between 0.35.0 and 0.37.1 are not recommended for hubot operations)

NOTE

If you want to integrate Rocket.Chat with GitHub or GitLab. Make sure you visit the Rocket.Chat.Ops project before starting. We already have many scripts that add webhook events and access GitHub/GitLab APIs. You can easily extend these scripts for your custom application.

For v2.x.x of the Adapter (Hubot v3 and ES6 support)

If you are writing CoffeeScript bots, need Hubot 2.x and v1.x.x or v0.x.x of the adapter, please see instructions for v1.x.x of the adapter.

The following instructions are ONLY for v2.x.x of the adapter.

Getting your bot connected to Rocket.Chat

Here is a sample run:

picture of a sample interaction with rocketbot

We have a couple of ways for you to get up and started with the Rocket.Chat adapter.

Docker

You can quickly spin up a docker image with:

docker run -it -e ROCKETCHAT_URL=<your rocketchat instance>:<port> \
	-e ROCKETCHAT_ROOM='general' \
	-e RESPOND_TO_DM=true \
	-e ROCKETCHAT_USER=bot \
	-e ROCKETCHAT_PASSWORD=bot \
	-e ROCKETCHAT_AUTH=password \
	-e BOT_NAME=bot \
	-e EXTERNAL_SCRIPTS=hubot-pugme,hubot-help \
	rocketchat/hubot-rocketchat
Custom Scripts

If you want to include your own custom scripts you can by doing:

docker run -it -e ROCKETCHAT_URL=<your rocketchat instance>:<port> \
	-e ROCKETCHAT_ROOM='general' \
	-e RESPOND_TO_DM=true \
	-e ROCKETCHAT_USER=bot \
	-e ROCKETCHAT_PASSWORD=bot \
	-e ROCKETCHAT_AUTH=password \
	-e BOT_NAME=bot \
	-e EXTERNAL_SCRIPTS=hubot-pugme,hubot-help \
	-v $PWD/scripts:/home/hubot/scripts \
	rocketchat/hubot-rocketchat

Creating a User on the Server

An admin user is required to create the account for the bot to login to.

  1. From Administration > Users menu
  2. Select + to make a new user
  3. Enter Name, Username, Email (tick verified) and Password
  4. Disable Require password change
  5. Select bot from role selection and click Add Role
  6. Disable Join default channels recommended, to avoid accidental listening
  7. Disable Send welcome email
  8. Save

Use these credentials in the bot's environment ROCKETCHAT_USER and ROCKETCHAT_PASSWORD

Note that for bots email, a common workaround to avoid creating multiple accounts is to use gmail +addresses, e.g. [email protected]. See this issue for more

Building a Bot

Please see our boilerplate bot [Getting Started docs here][getting-started]!

The boilerplate is essentially just a simple node package that requires Hubot, the Rocket.Chat adapter and Coffeescript for its execution...

"dependencies": {
    "coffeescript": "^2.2.2",
    "hubot": "3",
    "hubot-rocketchat": "^2.0.0"
}

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 rocketchat - will install dependencies and run the bot with this adapter.

More info in Hubot's own docs here

Configuring Your Bot

In local development, the following can be set in an .env file. In production they would need to be set on server startup.

The Rocket.Chat adapter implements the Rocket.Chat Node.js SDK to load all settings from the environment. So the following are just some of those settings, relevant to Hubot. It has some additional configs, documented here.

Env variable Description
Hubot A subset of relevant Hubot env vars
HUBOT_ADAPTER Set to rocketchat (or pass as launch argument)
HUBOT_NAME The programmatic name for listeners
HUBOT_ALIAS An alternate name for the bot to respond to
HUBOT_LOG_LEVEL The minimum level of logs to output (error)
HUBOT_HTTPD If the bot needs to listen to or make HTTP requests
Rocket.Chat SDK A subset of relevant SDK env vars
ROCKETCHAT_URL* Local Rocketchat address (start before the bot)
ROCKETCHAT_USER* Name in the platform (bot user must be created first)
ROCKETCHAT_PASSWORD* Matching the credentials setup in Rocket.Chat
ROCKETCHAT_ROOM The default room/s for the bot to listen in to (csv)
LISTEN_ON_ALL_PUBLIC DEPRECATED - DO NOT USE
RESPOND_TO_DM If the bot can respond privately or only in the open
RESPOND_TO_EDITED If the bot should reply / re-reply to edited messages
RESPOND_TO_LIVECHAT If the bot should respond in livechat rooms
`INTEGRATION_ID Name to ID source of messages in code (e.g Hubot)

* Required settings, unless running locally with testing defaults:

  • url: localhost:3000
  • username: bot
  • password: pass

Be aware you must add the bot's user as a member of the new private group(s) before it will respond.

Connecting to Rocket.Chat

We have a couple of ways for you to get up and started with the adapter below.

Docker

You can quickly spin up a docker image with:

docker run -it -e ROCKETCHAT_URL=<your rocketchat instance>:<port> \
	-e ROCKETCHAT_ROOM='general' \
	-e RESPOND_TO_DM=true \
	-e ROCKETCHAT_USER=bot \
	-e ROCKETCHAT_PASSWORD=bot \
	-e HUBOT_NAME=bot \
	-e EXTERNAL_SCRIPTS=hubot-help,hubot-diagnostics \
	rocketchat/hubot-rocketchat

Custom Scripts

If you want to include your own custom scripts you can by doing:

docker run -it -e ROCKETCHAT_URL=<your rocketchat instance>:<port> \
	-e ROCKETCHAT_ROOM='general' \
	-e RESPOND_TO_DM=true \
	-e ROCKETCHAT_USER=botname \
	-e ROCKETCHAT_PASSWORD=botpass \
	-e HUBOT_NAME=botname \
	-e EXTERNAL_SCRIPTS=hubot-help,hubot-diagnostics \
	-v $PWD/scripts:/home/hubot/scripts \
	rocketchat/hubot-rocketchat

Configuration Options

Here are all of the options you can specify to configure the bot.

On Docker you use: -e VAR=Value

Regular hubot via: export VAR=Value or add to pm2 etc

If ROCKETCHAT_URL is using https://, you MUST setup websocket pass-through on your reverse proxy (NGINX, and so on) with a valid certificate (not self-signed). Directly accessing Rocket.Chat without a reverse proxy via https:// is not possible.

Verify your bot is working

Try:

rocketbot ping

And:

rocketbot help

The example bot under scripts directory responds to:

rocketbot report status

v2.x.x Development

Docker

First clone the source and then move into the directory.

git clone [email protected]:RocketChat/hubot-rocketchat.git
cd hubot-rocketchat

Now we start the docker container.

docker run -it -e ROCKETCHAT_URL=<your rocketchat instance>:<port> \
	-e ROCKETCHAT_ROOM='general' \
	-e RESPOND_TO_DM=true \
	-e ROCKETCHAT_USER=bot \
	-e ROCKETCHAT_PASSWORD=bot \
	-e HUBOT_NAME=bot \
	-e EXTERNAL_SCRIPTS=hubot-help,hubot-diagnostic \
	-v $PWD:/home/hubot/node_modules/hubot-rocketchat rocketchat/hubot-rocketchat

Standard

In a Hubot instance once hubot-rocketchat is added by npm or yarn, you can replace the package with a development version directly:

  • cd node_modules from the bot's project root
  • rm -rf hubot-rocketchat to delete the published version
  • git clone [email protected]:RocketChat/hubot-rocketchat.git to add dev version
  • cd hubot-rocketchat move to dev path
  • npm install install dependencies

Linked

Setting up a locally linked package is easier for continued development and/or using the same development version of the adapter in multiple bots.

  • Change directory to your development adapter path
  • npm link or yarn link to set the origin of the link
  • Change directory to your bot's project root
  • npm link hubot-rocketchat or yarn link hubot-rocketchat to create the link

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.

For v1.x.x and v0.x.x of the Adatper

Docker-compose

If you want to use docker-compose for this task, add this for v0.1.4 adapter (this must be inserted in your docker-compose.yml):

# hubot, the popular chatbot (add the bot user first and change the password before starting this image)
hubot:
  image: rocketchat/hubot-rocketchat:v0.1.4
  environment:
    - ROCKETCHAT_URL=your-rocket-chat-instance-ip:3000 (e.g. 192.168.2.240:3000)
    - ROCKETCHAT_ROOM=general
    - RESPOND_TO_DM=true
    - ROCKETCHAT_USER=username-of-your-bot
    - ROCKETCHAT_PASSWORD=yourpass
    - BOT_NAME=bot
    - GOOGLE_API_KEY=yourgoogleapikey
# you can add more scripts as you'd like here, they need to be installable by npm
    - EXTERNAL_SCRIPTS=hubot-help,hubot-seen,hubot-links,hubot-diagnostics,hubot-google,hubot-reddit,hubot-bofh,hubot-bookmark,hubot-shipit,hubot-maps
  links:
    - rocketchat:rocketchat
# this is used to expose the hubot port for notifications on the host on port 3001, e.g. for hubot-jenkins-notifier
  ports:
    - 3001:8080

If you wish that your bot listen to all public rooms and all private rooms he is joined to let the env "ROCKETCHAT_ROOM" empty like in the example above and set the env "LISTEN_ON_ALL_PUBLIC" to true.

Please take attention to some external scripts that are in the example above, some of them need your Google-API-Key in the docker compose file.

Alternative Node.js installation with Node Version Manager (nvm) in a local environment on Debian/Ubuntu

# adduser hubot
# su - hubot
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
$ exit
# su - hubot
$ nvm install v4.8.5
$ npm update -g
$ npm install -g yo generator-hubot
$ mkdir hubot
$ cd hubot
$ yo hubot (answer questions and use "rocketchat" as adapter)
$ npm install coffee-script -save

Make sure ~/hubot/bin/hubot is executable: chmod 755 ./bin/hubot

If you need a redis database: apt install redis-server

Set node version: export NODE_VERSION=default

If you want to start your hubot with systemd use nvm-exec:

ExecStart=/home/hubot/.nvm/nvm-exec /home/hubot/hubot/bin/hubot --adapter rocketchat

See EnvironmentFile directive for using environment variables in systemd units

Add adapter to hubot

New install

You can specify the adapter during setup.

First you need to install hubot

npm install -g yo generator-hubot

Then you need to start the setup of the bot

mkdir myhubot
cd myhubot
yo hubot --adapter="rocketchat@1"

It'll ask you a few questions.

Alternatively you can actually answer the questions in one command:

yo hubot --owner="OWNER <[email protected]>" --name="bot" --description="Bot" --adapter="[email protected]"

Also be sure to remember the name you specify. This is what the bot will respond to in Rocket.Chat.

You will need to tell the adapter where your install is and what login information to use.

export ROCKETCHAT_ROOM='general'
export RESPOND_TO_DM=true
export ROCKETCHAT_USER=bot
export ROCKETCHAT_PASSWORD=bot
export ROCKETCHAT_AUTH=password

Then start with: bin/hubot -a rocketchat

More Info Here

Existing install

If you already have hubot setup you can add the adapter.

By doing: npm install hubot-rocketchat@2

You will need to tell the adapter where your install is and what login information to use.

export ROCKETCHAT_ROOM='general'
export RESPOND_TO_DM=true
export ROCKETCHAT_USER=rocketbot
export ROCKETCHAT_PASSWORD=bot
export ROCKETCHAT_AUTH=ldap

Then starting your bot specifying the adapter: bin/hubot -a rocketchat

Verify your bot is working

Try:

rocketbot ping

And:

rocketbot help

The example bot under scripts directory responds to:

rocketbot report status

Developers

We like to make development as easy on ourselves as possible. So passing the love on to you!

Adapter Development

We'd love to have your help improving this adapter. PR's very welcome ๐Ÿ˜„

Docker

First clone the source and then move into the directory.

git clone [email protected]:RocketChat/hubot-rocketchat.git
cd hubot-rocketchat

Now we start the docker container.

docker run -it -e ROCKETCHAT_URL=<your rocketchat instance>:<port> \
	-e ROCKETCHAT_ROOM='general' \
	-e RESPOND_TO_DM=true \
	-e ROCKETCHAT_USER=bot \
	-e ROCKETCHAT_PASSWORD=bot \
	-e ROCKETCHAT_AUTH=password \
	-e BOT_NAME=bot \
	-e EXTERNAL_SCRIPTS=hubot-pugme,hubot-help \
	-v $PWD:/home/hubot/node_modules/hubot-rocketchat rocketchat/hubot-rocketchat

Standard

Installed in hubot you'd hop over into node_modules.

Delete the hubot-rocketchat folder.

Then clone the git repo.

git clone [email protected]:RocketChat/hubot-rocketchat.git
cd hubot-rocketchat
npm install

Additional details

Look under the scripts directory, you will find a very basic bot there.

Just add your own script in the directory to have it loaded. If you are new to hubot script writing, find out more here.

If you find a bug or compatibility problem, please open an issue.

If you have any enhancements or feature requests, create an issue. If you like what you see, please star the repo.

Finally, if you have created a bot that other users may find useful, please contribute it.

Some 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.

CONTRIBUTORS WANTED

While it is functional, the current adapter is very basic. We need all the help we can get to add capabilities.

Become part of the project, just pick an issue and file a PR.

The adapter code is under the src directory. To test modified adapter code, exit (ctrl-c) the container and run it again.

FAQ

Q: I am not trying to stage a denial of service attack, why would I ever want to write a bot?

A: There are many positive and productive use cases for bots. Imagine a customer service support chat. As soon as a customer enters the support channel, a bot immediately identifies the customer and then:

  • fetches recent sales information from the sales dept server
  • fetches personal information from the customer data base
  • fetches latest notes made by her/his salesperson from the CRM system
  • scans the customer's facebook and twitter posts
  • obtains details of the last support ticket for this customer

Putting it altogether and then private message the service rep with the information.

Another use-case is a load test bot, imagine a bot that accepts the command:

rocketbot loadtest europe 25, asia 50, usa 100, canada 10

This command specifies a distribution of test bot instances, to be created across globally located data centers.

Once received, the bot:

  • parses the distribution
  • concurrently ssh to remote Kubernetes controllers and spawns the specified number of test bot instances to start the load test

Q: The architecture of hubot-rocketchat looks interesting, can you tell me more about it?

A: Sure, it is based on hubot-meteorchat. hubot-meteorchat is the hubot integration project for Meteor based chats and real-time messaging systems. Its driver based architecture simplifies creation and customization of adapter for new systems. For example, the hubot-rocketchat integration is just hubot-meteorchat + Rocket.Chat driver.

Learn more about hubot-meteorchat and other available drivers at this link.

hubot-rocketchat's People

Contributors

akurach avatar alexbrazier avatar bryanbecker avatar chkal avatar engelgabriel avatar fukuyama avatar garychapman avatar geekgonecrazy avatar kevinkuszyk avatar localguru avatar marceloschmidt avatar milionowa-firma-bot avatar niotex avatar nitoyon avatar paul-bjorkstrand avatar rhew avatar rodrigok avatar sdorra avatar shelnutt2 avatar sing-li avatar stefreak avatar strml avatar technicalpickles avatar thereal1604 avatar thinkeridea avatar thisiskj avatar timkinnane avatar vikaskedia avatar webflo avatar xiaket avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hubot-rocketchat's Issues

Add login retries

Current login try once and fails, making login problem difficult to debug.

Include more extensive logging. Help to identify as much as possible, the cause of the failure.

Include details (if available) of networking stack failure - for example, invalid SSL certs.

Get User Email Address From Script

Are we able to get the user``email address while in the script? So far, I can see in the message object we have:

message:
   { user:
      { id: 'ozCSNcrfcNJb2b7',
        name: 'johndoe',
        room: 'h7PdcWSubYw2zQy' },
     text: '@R2Z2: get circuit 61011',
     id: 'jMSMw4WtzvGQs9b',
     done: false,
     room: 'h7PdcWSubYw2zQy' },
  match:
   [ '@R2Z2: get circuit 61011',
     '61011',
     index: 0,
     input: '@R2Z2: get circuit 61011' ],
  envelope:
   { room: 'h7PdcWSubYw2zQy',
     user:
      { id: 'ozCSNcrfcNJb2b7',
        name: 'johndoe',
        room: 'h7PdcWSubYw2zQy' },
     message:
      { user: [Object],
        text: '@R2Z2: get circuit 61011',
        id: 'jMSMw4WtzvGQs9b',
        done: false,
        room: 'h7PdcWSubYw2zQy' } } }

I can get the User name but now wondering if there is a way to pull the email address either from rocket.chat or the LDAP instance using the name?

bot is not connecting with latest version of rocket.chat

After a clean clone of both chat and bot, the bot will not response to anything

[Tue Jul 28 2015 15:11:53 GMT+0000 (UTC)] WARNING No services ROCKETCHAT_URL provided to Hubot, using 10.0.0.121:3000

[Tue Jul 28 2015 15:11:53 GMT+0000 (UTC)] WARNING No services ROCKETCHAT_ROOM provided to Hubot, using general

[Tue Jul 28 2015 15:11:53 GMT+0000 (UTC)] WARNING No services ROCKETCHAT_USER provided to Hubot, using rocketbot

[Tue Jul 28 2015 15:11:53 GMT+0000 (UTC)] INFO running rocketchat
[Tue Jul 28 2015 15:11:53 GMT+0000 (UTC)] INFO login
[Tue Jul 28 2015 15:11:54 GMT+0000 (UTC)] INFO logged in
[Tue Jul 28 2015 15:11:54 GMT+0000 (UTC)] INFO joined room
[Tue Jul 28 2015 15:11:54 GMT+0000 (UTC)] INFO prepare meteor subscriptions

Hubot Joining Channels Not Defined In ROCKETCHAT_ROOM

I have two Hubot instances running and they are joining channels that I have not specified in their ROCKETCHAT_ROOM env variable. Even though they sit in the incorrect public channels, they reply/respond according to what is defined in ROCKETCHAT_ROOM.

Read configuration parameters from environment variables

Read the currently 'hard coded' configuration parameters from the process's environment variables.

It may be helpful to have an additional capability to read these from a file (since execution environments such as Docker container can mount volumes).

Usage with docker-compose

Hi. I'm trying to setup rocketchat/hubot-rocketchat and rocketchat/rocket.chat to work together with docker-compose. My docker-compose.yml:

db:
  image: mongo
  volumes:
    - ./data/runtime/db:/data/db
    - ./data/dump:/dump
  command: mongod --smallfiles

rocketchat:
  image: rocketchat/rocket.chat
  environment:
    - MONGO_URL=mongodb://db:27017/rocketchat
    - ROOT_URL=http://localhost:8818
  links:
    - db:db
  ports:
    - 8818:3000

hubot:
  image: rocketchat/hubot-rocketchat
  links:
    - rocketchat:rocketchat
  environment:
   -  ROCKETCHAT_URL=http://rocketchat:3000
   -  ROCKETCHAT_ROOM=GENERAL
   -  ROCKETCHAT_USER=bot
   -  ROCKETCHAT_PASSWORD=bot
   -  BOT_NAME=bot
   -  EXTERNAL_SCRIPTS=hubot-pugme,hubot-help

But it seem to not work for me. hubot container shows me only:

hubot_1      | [email protected] node_modules/hubot-help
hubot_1      | 
hubot_1      | [email protected] node_modules/hubot-pugme
...
hubot_1      | [Sat Oct 31 2015 13:40:22 GMT+0000 (UTC)] INFO Starting Rocketchat adapter...
hubot_1      | [Sat Oct 31 2015 13:40:22 GMT+0000 (UTC)] INFO Once connected to rooms I will respond to the name: bot
hubot_1      | [Sat Oct 31 2015 13:40:22 GMT+0000 (UTC)] INFO Connecting To: http://rocketchat:3000

I also tried to run boot service from shell (using docker-compose.yml listed before):

$ docker-compose run --service-ports hubot bash
hubot@6924d55fb96d:~$ bin/hubot -n $BOT_NAME -a rocketchat

It shows all the same:

[Sat Oct 31 2015 14:08:28 GMT+0000 (UTC)] INFO Starting Rocketchat adapter...
[Sat Oct 31 2015 14:08:28 GMT+0000 (UTC)] INFO Once connected to rooms I will respond to the name: bot
[Sat Oct 31 2015 14:08:28 GMT+0000 (UTC)] INFO Connecting To: http://rocketchat:3000

Pinging rocketchat and curl http://rocketchat:3000 from hubot container works well.

Also I created bot user with the same password via user registration form.

Note: all other chat functions and chat itself works just fine. Only hubot is not working. I don't see any message from it and new commands are not appear after I type /

What am I doing wrong?..

Bot ignore other bots

Need to respect other bots. In a multi-bots environment. Bots 'chatter' can ping-pong for minutes ! ๐Ÿ˜ฎ

Define and implement channel / room join policies for bots

This is a tough one.

  • too rigid and some yet-to-be-imagined innovative bot use-cases will be blocked
  • too permissive and it will be open invitation for DoS and assorted abuses

This also depends heavily on the eventual security model / vision (and channels grouping / ownership hierarchy strategy) that the core team has in mind.

For the time being, it is probably wise to err on the permissive side.

What do you guys think?

Handle Direct Messages

I am unable to find anything that allows Hubot to respond to direct messages. This is useful so that users can interact with him without spamming the chat.

Heroku alive exclusion

I get the following error

ERROR hubot-heroku-alive included, but missing HUBOT_HEROKU_KEEPALIVE_URL. heroku config:set HUBOT_HEROKU_KEEPALIVE_URL=$(heroku apps:info -s | grep web_url | cut -d= -f2)

however removing

npm uninstall hubot-heroku-keepalive

causes the bot not to start at all

ERROR Error loading scripts from npm package - Error: Cannot find module 'hubot-heroku-keepalive'

Bot not completing login process?

I'm running the bot via command line: bin\hubot -a rocketchat.
I've got DEBUG enabled, so I can get as much output as possible.
Here's the output during startup, which just hangs at the end.
[Mon Sep 21 2015 11:41:30 GMT-0500 (CDT)] INFO logged in
[Mon Sep 21 2015 11:41:30 GMT-0500 (CDT)] INFO joining room
[Mon Sep 21 2015 11:41:30 GMT-0500 (CDT)] INFO joined room
[Mon Sep 21 2015 11:41:30 GMT-0500 (CDT)] INFO Preparing Subscriptions
[Mon Sep 21 2015 11:41:30 GMT-0500 (CDT)] INFO prepare meteor subscriptions
[Mon Sep 21 2015 11:41:30 GMT-0500 (CDT)] INFO data.roomid == general

I expect to see "subscription ready" output from
https://github.com/RocketChat/hubot-rocketchat/blob/master/src/rocketchat.coffee#L33
but it never comes out as it's the very next line in the code??

Thanks!

Npm is not up to date

doing a npm install hubot-rocketchat does not have this commit bb55a88, which means the adapter will not work. Npm needs to be updated with master or potentially start using tags on this repo.

Switch to ddp library with more events

Looking at some other ddp libraries. We're missing some important events like disconnect and reconnect. Our current one the maintainers haven't updated in a while. So might be worth looking at some more complete alternatives. Or at least something we can work with.

Here's one:
https://www.npmjs.com/package/ddp

I'll update with others I find.

Create Docker images(s) to simplify adapter development

It is difficult to set up the environment for hubot integration development. Multiple subsystems and their complex dependencies need to be installed and configured precisely, with exact matching configuration from a running Rocket.Chat instance for things to work.

This problem is not unique to the Rocket.Chat integration, but common to all hubot <-> chat integrations - and is a 'classic' use case for Docker.

Create Docker image(s) and matching docs to eliminate the need for complex setup.

Message does not appear in RocketChat

Hey guys,

I tried to use the docker images of RocketChat (0.5.0) with the latest hubot-rocketchat.
In the logs of RocketChat I see the following:

[functions] RocketChat.sendMessage ->  arguments: { '0': { _id: 'vc23ZEswYR5hu9q8q', username: 'timo.litzius' },
  '1': { rid: '4K5xMvFttPTGKiNse', msg: 'try' },
  '2': { _id: '4K5xMvFttPTGKiNse', t: 'c', name: 'botty' } }
{ rid: '4K5xMvFttPTGKiNse',
  msg: 'try',
  ts: Sun Oct 04 2015 15:17:26 GMT+0000 (UTC),
  u: { _id: 'vc23ZEswYR5hu9q8q', username: 'timo.litzius' },
  _id: 'bLczJQMam4p3xR2xn' }
ROCKETCHATADAPTER -> send
send 4K5xMvFttPTGKiNse: Trying is the first step towards failure. (timo.litzius)

Looks like the bot can pickup my messages but the response never appears in the channel.
Any ideas?

Cheers
Timo

bot is not connected

When I the docker image the output is

[Tue Jun 09 2015 15:41:01 GMT+0000 (UTC)] INFO running rocketchat
[Tue Jun 09 2015 15:41:01 GMT+0000 (UTC)] INFO login

I try creating a user bot and rocketbot but is still not working

this are my configs

_meteorurl = "192.168.0.11:3000"
_hubotuser = "rocketbot"
_hubotpassword = "demodemo"
_roomid = "57om6EQCcFami9wuT"

to run the container I copy/paste the same command from inside the clones repo

On Enter hooks

Hubot needs to be able to get on enter events. For things like hubot-tell that needs to be able to tell someone something when it sees them next.

Auto-subscribe to room when invited

Currently when you invite the rocketchat hubot to a room, he will not respond to any commands; I am assuming this is because he doesn't have a meteor subscription. In slack, if you invite hubot to a room, he automatically is available to chat with, you do not need to modify the configuration file to add those rooms.

Handle complex passwords

Currently implementation fails when there is interesting characters, like '@' signs, in passwords.

Rocket Chat Hubot Adapter is not replying back for the commands

Hi,

Whenever i am running hubot with rocket chat adapter, it is giving the following output, and also not going to cli prompt. and if i am ping from Rocket chat url , it is just telling change received with the corresponding ID. There is no reply is coming back to chat window. I have put some external scripts to hear my command.

If i run without the rocket adapter , i am able to hear the command and respond back via Emit or reply.

Please help me to resolve the issue.

D:\webshot\myhubot>bin\hubot -a rocketchat
[Thu Oct 08 2015 17:02:55 GMT+0530 (India Standard Time)] INFO Starting Rocketchat adapter...
[Thu Oct 08 2015 17:02:55 GMT+0530 (India Standard Time)] INFO Once connected to rooms I will respond to the name: GroceryOps
[Thu Oct 08 2015 17:02:55 GMT+0530 (India Standard Time)] INFO Connecting To: 172.28.135.145:3000
[Thu Oct 08 2015 17:02:55 GMT+0530 (India Standard Time)] INFO Successfully Connected!
[Thu Oct 08 2015 17:02:55 GMT+0530 (India Standard Time)] INFO GENERAL
[Thu Oct 08 2015 17:02:55 GMT+0530 (India Standard Time)] INFO Logging In
[Thu Oct 08 2015 17:02:55 GMT+0530 (India Standard Time)] INFO D:\webshot\myhubot\scripts\example.coffee is using deprecated documentation syntax
[Thu Oct 08 2015 17:02:55 GMT+0530 (India Standard Time)] INFO D:\webshot\myhubot\scripts\router.coffee is using deprecated documentation syntax
[Thu Oct 08 2015 17:02:56 GMT+0530 (India Standard Time)] INFO Successfully Logged In
[Thu Oct 08 2015 17:02:56 GMT+0530 (India Standard Time)] INFO Joining Room: GENERAL
[Thu Oct 08 2015 17:02:56 GMT+0530 (India Standard Time)] INFO all rooms joined
[Thu Oct 08 2015 17:02:56 GMT+0530 (India Standard Time)] INFO Successfully joined room: GENERAL
[Thu Oct 08 2015 17:02:56 GMT+0530 (India Standard Time)] INFO Preparing Meteor Subscriptions..
[Thu Oct 08 2015 17:02:56 GMT+0530 (India Standard Time)] INFO Subscribing to Room: GENERAL
[Thu Oct 08 2015 17:02:56 GMT+0530 (India Standard Time)] INFO all subscriptions ready
[Thu Oct 08 2015 17:02:56 GMT+0530 (India Standard Time)] INFO Successfully subscribed to room: GENERAL
[Thu Oct 08 2015 17:02:56 GMT+0530 (India Standard Time)] INFO Setting up reactive message list...
[Thu Oct 08 2015 17:03:02 GMT+0530 (India Standard Time)] INFO Change received on ID hrJtvGtMEYGpwf9ng

rename ROCKETCHAT_URL

Can be stupid but I lost 5 min to understand that ROCKETCHAT_URL is not asking an URL as defined on spec https://url.spec.whatwg.org/#url-syntax because absolute URL should have a scheme.

-e ROCKETCHAT_URL=http://my-instance.local:3000

does not work!

It can be renamed by ROCKETCHAT_INSTANCE or something else

hubot does not finish login

Hubot-rocketchat cannot successfully finish loggin.

ERROR message follows:

selection_001

I am using latest rocket.chat master branch, HEAD:1875e3 (Sep 22), as well as latest hubot-rocketchat (Sep 24).

Hubot-rocketchat was started in development mode (hubot -a rocketchat).

URL doesn't accept http(s)

It should still work if you have http:// at the beginning of your ROCKETCHAT_URL, or at least tell you why it's not working

Keeping Hubot Alive and Run As Daemon

Just wondering how you guys are keeping Hubot alive and running as a daemon? My first thought was to use Forever, but it looks like Forever expects javascript.

hubot wont authenticate agains ldap

while the bot is able to login via the webinterface

[Fri Oct 09 2015 14:17:55 GMT+0200 (CEST)] WARNING No services ROCKETCHAT_URL provided to Hubot, using localhost:3000
[Fri Oct 09 2015 14:17:55 GMT+0200 (CEST)] INFO Connecting To: localhost:3000
[Fri Oct 09 2015 14:17:55 GMT+0200 (CEST)] INFO Successfully Connected!
[Fri Oct 09 2015 14:17:55 GMT+0200 (CEST)] INFO testbot
[Fri Oct 09 2015 14:17:55 GMT+0200 (CEST)] INFO Logging In
[Fri Oct 09 2015 14:17:55 GMT+0200 (CEST)] ERROR hubot-heroku-alive included, but missing HUBOT_HEROKU_KEEPALIVE_URL. `heroku config:set HUBOT_HEROKU_KEEPALIVE_URL=$(heroku apps:info -s  | grep web_url | cut -d= -f2)`
[Fri Oct 09 2015 14:17:56 GMT+0200 (CEST)] INFO hubot-redis-brain: Using default redis on localhost:6379
[Fri Oct 09 2015 14:17:56 GMT+0200 (CEST)] ERROR Unable to Login: [object Object] Reason: User has no password set

and this is what I capture via tcpdump

{"error":403,"reason":"User has no password set","message":"User has no password set [403]","errorType":"Meteor.Error"}}

"subscription ready" never hit

I run the docker container and it successfully connects to the room but the "subscription ready" message is never logged and the bot won't respond.

My full output looks like this:

$ docker run -it --rm -v $PWD:/home/hubot/node_modules/hubot-rocketchat -v $PWD/scripts:/home/hubot/scripts -e ROCKETCHAT_URL=192.168.X.X:3000 -e ROCKETCHAT_PASSWORD=password -e ROCKETCHAT_ROOM=general -e ROCKETCHAT_USER=hubot singli/hubot-rocketchat
[email protected] node_modules/hubot-maps

[email protected] node_modules/hubot-help

[email protected] node_modules/hubot-shipit

[email protected] node_modules/hubot-diagnostics

[email protected] node_modules/hubot-google-images

[email protected] node_modules/hubot-pugme

[email protected] node_modules/hubot-rules

[email protected] node_modules/hubot-google-translate
[Tue Sep 22 2015 19:51:42 GMT+0000 (UTC)] INFO running rocketchat
[Tue Sep 22 2015 19:51:43 GMT+0000 (UTC)] INFO first room general
[Tue Sep 22 2015 19:51:43 GMT+0000 (UTC)] INFO login
[Tue Sep 22 2015 19:51:43 GMT+0000 (UTC)] INFO logged in
[Tue Sep 22 2015 19:51:43 GMT+0000 (UTC)] INFO joined room
[Tue Sep 22 2015 19:51:43 GMT+0000 (UTC)] INFO prepare meteor subscriptions
[Tue Sep 22 2015 19:51:43 GMT+0000 (UTC)] INFO data.roomid == general

I can see the bot has entered the room. I also put some additional logging inside the message handler and I can't see any output.

Create automated delivery pipeline (CI / Continuous Integration)

Use travis-ci to create a delivery pipeline that will, upon the push of a tagged commit:

  • build the adapter
  • (test) the adapter code [tests TBD]
  • creates and pushes the distribution NPM module to NPM registry
  • build the rocketchat/hubot-rocketchat docker image

Stopping at any of the above steps and break pipeline on failure.

Additional feature (separate ticket later):
Integrate status webhooks with bots in DEMO.

Stop bot from re-processing 'already processed' messages

Bot now has no memory of which message has been processed.

Robot.Chat's current design may cause the same message to be repeatedly presented to the bot.

Quick fix is for bot to remember the Msg ID of the most current 'threshold' number of messages processed. Threshold can be set to 100 or so for now?

Another possible 'fix' is to have an actual FLAG on the message to indicate 'bot processed'.

Fix bot in multiple rooms implementation

The current implementation has a serious bug.

Currently, if the bot is asked to join 15 rooms - it will:

  • create a subscription to each room
  • setup reactive updates handler for each room

BUT - server side, the subscriptions are actually merged.

This means you end up with 15 handlers all going through the same merged subscription. CPU exhaustion is observed with increased number of rooms.

The code needs to be modified to:

  • create a subscription for all the rooms
  • setup A SINGLE reactive updates handler for all the rooms - based on the final merged subscription

Thanks to john.sinteur from the RC community for reporting this subtle problem.

Expose error on failed login attempt

Currently there's no error if login doesn't succeed, although I've tried to include some try/catch + error callback while learning Coffeescript it still doesn't return anything helpful to understand why it doesn't login.

The call itself stops here and no code inside gets executed and no error is returned to its promise hence 'catch' doesn't get executed:

@chatdriver.login(RocketChatUser, RocketChatPassword).then (userid) =>

Any error callback or something that can expose what went wrong is more than helpful.

I thought the issue was with the password containing special characters like '@' but even if I changed to a simple one 'password12' it didn't work.

That's the loginWithPassword function in Asteroid that I found so far but couldn't make much progress with Coffeescript here:

https://github.com/mondora/asteroid/blob/master/src/core/login.js

PS: Tried running RocketChat locally without SSL and didn't work either

Tks a lot

Track schema and RPC method changes during rapid core code restructuring

The RocketChat core team is rapidly restructuring core code - especially the Meteor pub-sub internals.

hubot-rocketchat depends on a server-side Meteor messages publication, ordered by timestamp, to work.

Even before the first pull request has been merged down, the original 'dashboardRoom' publication has already disappeared. In its place, a new 'messages' publication is now available. This may change again (?) as restructuring continues.

The reference to this publication is around line 5 of src/rocketchat_driver.coffee.

_msgsubtopic = 'dashboardRoom'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.