DEV Community 👩‍💻👨‍💻

sfrunza13
sfrunza13

Posted on

Planning 0.4

The beginning of the end

The final project in my open source course is a final contribution to a repository of our choice, this time it has to be a series of bug fixes or a feature, meaning actually adding code to a repository. Ideally these contributions should scale in difficulty.

I have in the past added code to several repositories, contributions that I would consider features, I wanted to continue my streak here and got to searching. I used this page to start searching through projects to find one that I thought I could add to: https://github.com/MunGell/awesome-for-beginners. This is actually a great resource and I think I might come back to it again in the future.

The project

I decided to add to an open source Python based chat bot called opsdroid. I was initially worried about whether I had what it takes to do another code contribution on time, learning an entirely new project is always daunting. I brought it up to my professor David and he encouraged me to go for it, an honest attempt at something beyond my capabilities would be taken into consideration for the final project and to "be fearless. don't let code push you around.

The issue

The issue in question: https://github.com/opsdroid/opsdroid/issues/1941. The opsdroid is a highly customizable chat bot that can be made to work with several chatting services such as Slack, which is what this issue centers around. Currently the default behavior of the bot is to return regular messages in a channel and yypptest suggested the addition of an option to use Ephemerals as well, which is a type of Slack message that is temporarily displayed in a chat channel for a specific user.

I checked and it seems to be a similar kind of post request as the regular message.

Checking out documentation

A little while after I started looking for information and trying to set up my local opsdroid to play around, I became glad I took this issue. The opsdroid documentation is brilliant! So is the slack documentation on bots, tokens and APIs that I would need to use.

Getting setup

So far I downloaded ngrok to expose a port to the web to allow my local opsdroid to communicate with Slack API, and I created a slack app for the test bot with the permissions it needed and read the opsdroid docs on how to configure the tokens and settings required to get a basic droid running in a configuration.yaml. This was my first configuration:

welcome-message: true
web:
  base-url: https://de90-99-229-14-205.ngrok.io/
connectors:
 slack:
   # required
   bot-token: "xoxb-hahahahaImNotPuttingThatHere"
   # optional
   socket-mode: false # default true
   start-thread: false # default false, if true opsdroid will reply in a thread
   bot-name: "mybot" # default "opsdroid"
   default-room: "#random" # default "#general"
   icon-emoji: ":smile:" # default ":robot_face:"
  #  response-type: "in-channel"
skills:
  ## Dance (https://github.com/opsdroid/skill-dance)
  dance: {}

  ## Hello (https://github.com/opsdroid/skill-hello)
  hello: {}

  ## Loudnoises (https://github.com/opsdroid/skill-loudnoises)
  loudnoises: {}

  ## Seen (https://github.com/opsdroid/skill-seen)
  seen: {}
logging:
  level: debug
Enter fullscreen mode Exit fullscreen mode

I got my bot to dance:

Image description

Looking to the future

I am going to check what the difference is between the message and ephemeral API and see if I can pull the choice for which to use from the config.yaml, then actually get an ephemeral to send to the user that triggers the bots skill instead of just a regular message in channel.

Top comments (0)

Hey 😍

Want to help the DEV Community feel more like a community?

Head over to the Welcome Thread and greet some new community members!

It only takes a minute of your time, and goes a long way!