Progress
Tags: opensource, python, git, programming
Published: 2022-12-04 17:35:06

## Ground Work

Like with any other project the beginnings of progress come from reading up a bit on what it is you are working with. Luckily for me I am attempting to work on ops-droid's slack connector to send ephemeral messages and there is some great documentation for the ops-droid to get it set up locally with it's slack connector and to make it connect as an App to a slack channel, in my case through exposing the port that the ops-droid is running on through ngrok. There is also a lot of great documentation on slack's part about the different post methods and APIs that our bot can consume.

Here are some links to some of the stuff mentioned above:
* [ngrok](https://ngrok.com/)
* [ops-droid docs](https://docs.opsdroid.dev/en/stable/)
* [slack docs](https://api.slack.com/methods)

## Getting started

The problem at hand for me was as follows:
> Ability to send Ephemeral respond for slack connector. User is able to have option to send the respond as `in_channel` or `ephemeral` when sending responds, thanks!

To get started with this I took a look at how the regular messages were being posted and I checked to see the difference between the regular message post method and the ephemeral message post method in the slack documentation.

The primary difference I found was that the post method for messages did not require a user's ID to be passed in the request because it would be posting the message to the channel for everyone to see, whereas the post method for the ephemeral required a user's ID so that it would know which user should be allowed to see the more temporary and private ephemeral message.

My thought was to first create a successful post of an ephemeral through my local bot and to open a PR and ask for input on it to see in which direction the maintainers would want to take the solution. My idea to get it working initially was to create a new field to be specified in the .yaml file the same way the issue mentioned, allowing the creator of the bot to specify between `in_channel` and `ephemeral` before using the bot. I don't know right now if this is the way it will end up in the final solution but this is what I chose to do to get started. I then went to the post method for message and added a conditional statement that checked to see which of the options was specified and based on that would post using the message method or the ephemeral method.

The final problem of the first implementation was that I did not know where to get the user ID from immediately. The Message event that was already defined did not have user ID as one of the specified attributes in the docstring, but after testing it out I found that it was an attribute that was accessible it was just not mentioned in the docstring.

After that realization I added the user ID to the request and got my first ephemeral to send through using the built in greeting skill of the chat bot:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sua0hg3g1zcz8hnsh1zo.png)

## Future work

Now I face a few problems, firstly I am failing every CI test that they have basically on my draft PR. Secondly, I need to get some feedback from the maintainers to know that I am on the right track and I am not ruining everything.

So in the coming week I will have to check if I can manage to get the tests to pass on what I have written, and what is going wrong and since no one has commented on my draft PR for a few days now I will have to get involved in one of their chat forums and ask for help since I do not really know what my next steps are right now.