Slack Bot integration with FunRetro
JavierLight opened this issue · 26 comments
Description
Fun Retro integration into Slack using a bot.
Motivation
Would be great to be able to type /newfunretro
in a Slack team chat and get the link for a new FunRetro (instead of creating a new one using the buttons in the webpage). A customizable Name for the Board would be passed as an argument in this command.
Why do I need your help?
I would be more than pleased to contribute creating the Slack Bot, but I would like to know if you can find an easy way to provide this service via a new endpoint in your website (which would return the New Board URL). My alternative would be programatically creating a new user and appending that AuthO user ID
to the href.window.location
redirection, which doesn't look very elegant for me.
The problem is that we don't have server side for that app right now. So there is no way of creating an endpoint for that. But maybe we can create a simple server in order to do that. That would be great to do actually.
I'm sorry I didn't explain myself properly. What I meant is to avoid the need to:
- Press on the
New Board
button. - Input the name of the board.
- Press again the
New Board
button.
If you could create a new endpoint being http://funretro.github.io/distributed/newboard?name, its response being the URL of the new board, that would be perfect for me to create the Slack Bot. A simple GET
request could be the easiest way, right?
I'm assuming this would be possible as long as there is no actual user being logged in (which currently seems to be the situation).
Thank you very much for your time :)
That's the issue, the application right now is pure static, only runs on the client side. There is no way of creating what you are asking for. There is no code running on the server side. We use a service called Firebase that handles everything, and that server is called from the client side.
We would need to create a simple node express server to handle what you are asking.
Did you understand now?
Sorry again, I misunderstood your first message. That would be awesome! Hoping that somebody can create that simple node express server (I don't even know how to start).
Yeah I think it would be nice to create this simple node express server. I will see if I can do it on my free time but right now I am quite busy. It would be nice if someone else tries it as well. Maybe @pamo, @Roshanjossey or @brunapereira ?
@glauberramos, is there a way we can do this with firebase itself? I see there is a feature called functions. I'll dig deeper on this and come back to you
Hi @glauberramos , I'm new to contributing and to this project, but I might be able to help you out with creating the node express server.
hey @juventinoromero, I think we should try first @Roshanjossey suggestion to use firebase functions. Can you install a local funretro version on your local machine and try to use firebase functions in order to create a board and return a board URL?
@glauberramos sure, I'll give it a shot.
Hello @glauberramos, I think I can implement firebase functions. I've taken a look to the code but can't seem to understand how the app interacts with firebase.
I think I can implement firebase functions
@juventinoromero, that's awesome.
can't seem to understand how the app interacts with firebase.
I'll share what I understood by reading code here. @glauberramos, please jump in and correct me if I'm wrong.
Currently we're only using database feature of firebase.
To know more, read through https://github.com/funretro/distributed/blob/master/js/services/firebaseService.js and https://github.com/funretro/distributed/blob/master/js/mainController.js.
firebaseService.js
is where we've extracted out all firebase actions as utility functions. You can see usages of these functions in mainController.js
thanks @Roshanjossey! I'm checking it out and it starts to make sense. I think the createNewBoard function in mainController.js is the one I need to implement in the /newRetro endpoint, isn't it?
Yeah @juventinoromero, that's the method we need to implement.
Hey @glauberramos and @Roshanjossey , I'm not sure how to implement the createNewBoard in the firebase function. I'm not sure how angularworks and how to proceed with those $scope calls you make. Can you take a look at this file and somehow give me some guidance? https://github.com/juventinoromero/distributed/blob/newboard-endpoint/functions/index.js
Hello @juventinoromero.
I don't think you should use angular at all or any other file from the application. Your function should be separated from the rest of the application.
I suggest you to use hardcoded values. You can copy the messageTypes, use 6 for max_votes, text_editing_is_private should be true. Also you should not use firebaseService but you should call firebase direct from your file (just copy the function). Also you should not use $scope.
Does this helps you?
@glauberramos, it does! Thanks
The api successfully creates a new user and a new board. @glauberramos can you insert the correct database info in firebaseInitialization.js to check if it works?
@juventinoromero the code worked perfectly
@JavierLight we now have the endpoint you need for creating the slack bot. Here is the endpoint: https://us-central1-blinding-torch-6662.cloudfunctions.net/newboard?name=test
@glauberramos great news!
I think this is on hold, if you want to implement the slack plugin please go ahead @Kiri23
Firebase functions
You can check that on package.json