1. Home
  2. Docs
  3. People Ops
  4. Opsdroid (Engineering)

Opsdroid (Engineering)

We use Opsdroid mainly to assist People Ops-related processes, and also to assist engineering.

Initial Impressions

So far, considering that:

  • Opsdroid’s Rocket.Chat connector crashes when Rocket.Chat throws HTTP error
  • Opsdroid’s Rocket.Chat connector can only connect to one channel
  • Opsdroid’s Rocket.Chat connector can’t even respond to private chats
  • Opsdroid still needs integration with Rasa for NLU support
  • Opsdroid doesn’t have prebuilt ChatOps skills or a skills repository/marketplace
  • Rasa provides outgoing-only Rocket.Chat integration, although practically we need to implement our own custom Rocket.Chat connector
  • Rasa has much more NLU features, supports language models, and we want to be experts in Rasa

Hendy’s conclusion is that we should use Rasa directly.

Installation

Launch a t4g.nano (0.5 GB) instance. First, run the usual Ubuntu preparation.

Edit .bashrc and add PATH:

# not needed, just install opsdroid globally using sudo
#export PATH=$PATH:$HOME/.local/bin
pip3 install -U pip
sudo apt install -y python3-pip language-pack-en git
sudo pip3 install -U opsdroid

Run temporarily:

opsdroid start

Run for real (with auto-restart on crash):

yarn global add pm2
~/.yarn/bin/pm2 init

Edit ecosystem.config.js:

  apps : [{
    name: 'opsdroid',
    cmd: 'opsdroid',
    args: 'start',
    interpreter: 'python3',
    time: true
  }],
pm2 start ecosystem.config.js
~/.yarn/bin/pm2 logs

Opsdroid Web

Note: Opsdroid Web and Opsdroid Desktop never updated since 2019, and will give warnings/errors with Node.js v14+.

curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs
## You may also need development tools to build native addons:
     sudo apt-get install gcc g++ make
## To install the Yarn package manager, run:
     curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
     echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
     sudo apt-get update && sudo apt-get install yarn

git clone https://github.com/opsdroid/opsdroid-web.git
cd opsdroid-web
# Warning: This requires > 0.5 GB memory, otherwise it will crash the server
yarn install
yarn start

TODO: Ping Skill

TODO: Connect to Rocket.Chat

Reference: Opsdroid Rocket.Chat connector

Edit .config/opsdroid/configuration.yaml:

connectors:
  rocketchat:
    # required
    user-id: "1ioKHDIOD"
    token: "zyxw-abdcefghi-12345"
    # optional
    bot-name: "loviateam" # default "opsdroid"
    default-room: "sandbox" # seems to have no effect when group is set
    group: "skywalkers" # default to None
    channel-url: "https://chat.lovia.life" # defaults to https://open.rocket.chat
    update-interval: 5 # defaults to 1

Problem: https://github.com/aio-libs/aiohttp/issues/5315

INFO opsdroid.core: Opsdroid is now running, press ctrl+c to exit.
INFO opsdroid.connector.rocketchat: Connecting to Rocket.Chat
Traceback (most recent call last):
  File "/usr/local/bin/opsdroid", line 8, in <module>
    sys.exit(cli())
  File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/opsdroid/cli/start.py", line 43, in start
    opsdroid.run()
  File "/usr/local/lib/python3.8/dist-packages/opsdroid/core.py", line 172, in run
    self.eventloop.run_until_complete(self.start())
  File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.8/dist-packages/opsdroid/core.py", line 187, in start
    await self.start_connectors()
  File "/usr/local/lib/python3.8/dist-packages/opsdroid/core.py", line 384, in start_connectors
    await asyncio.gather(*[connector.connect() for connector in self.connectors])
  File "/usr/local/lib/python3.8/dist-packages/opsdroid/connector/rocketchat/__init__.py", line 92, in connect
    resp = await self.session.get(self.build_url("me"), headers=self.headers)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/aiohttp/client.py", line 492, in _request
    req = self._request_class(
  File "/home/ubuntu/.local/lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 305, in __init__
    self.update_host(url)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 366, in update_host
    raise InvalidURL(url)
aiohttp.client_exceptions.InvalidURL: %3Cfunction%20Url%20at%200xffff948ebe50%3E/api/v1/me
ERROR: Unhandled exception in opsdroid, exiting...
{'client_session': <aiohttp.client.ClientSession object at 0xffff948ecdf0>, 'message': 'Unclosed client session'}
INFO opsdroid.core: Opsdroid is now running, press ctrl+c to exit.
INFO opsdroid.connector.rocketchat: Connecting to Rocket.Chat
Traceback (most recent call last):
  File "/usr/local/bin/opsdroid", line 8, in <module>
    sys.exit(cli())
  File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/opsdroid/cli/start.py", line 43, in start
    opsdroid.run()
  File "/usr/local/lib/python3.8/dist-packages/opsdroid/core.py", line 172, in run
    self.eventloop.run_until_complete(self.start())
  File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.8/dist-packages/opsdroid/core.py", line 187, in start
    await self.start_connectors()
  File "/usr/local/lib/python3.8/dist-packages/opsdroid/core.py", line 384, in start_connectors
    await asyncio.gather(*[connector.connect() for connector in self.connectors])
  File "/usr/local/lib/python3.8/dist-packages/opsdroid/connector/rocketchat/__init__.py", line 92, in connect
    resp = await self.session.get(self.build_url("me"), headers=self.headers)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/aiohttp/client.py", line 492, in _request
    req = self._request_class(
  File "/home/ubuntu/.local/lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 305, in __init__
    self.update_host(url)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 366, in update_host
    raise InvalidURL(url)
aiohttp.client_exceptions.InvalidURL: %3Cfunction%20Url%20at%200xffff948ebe50%3E/api/v1/me
ERROR: Unhandled exception in opsdroid, exiting...
{'client_session': <aiohttp.client.ClientSession object at 0xffff948ecdf0>, 'message': 'Unclosed client session'}

Solution: Needs patching.

Problem: ERROR opsdroid.connector.rocketchat: Rocket.Chat error 502,

Solution: Redeploy Rocket.Chat server and ensure it is up.

TODO: MongoDB

TODO: Send on-demand update of weather

TODO: Send on-demand update from GitLab User Activities

TODO: Scheduled Daily update of GitLab User Activities

TODO: On-demand Standup meeting

TODO: Scheduled Daily Standup meeting

TODO: Rasa

Alternatives Considered

  1. Geekbot. Probably the best. $3/participant/month. Slack only.
  2. DailyBot. Slack / Teams / Google Chat.
  3. bahaso/rocket-daily-standup. Open source. Rocket.Chat. Abandoned since Feb 2019.

How can we help?

Leave a Reply

Your email address will not be published. Required fields are marked *