distributed icon indicating copy to clipboard operation
distributed copied to clipboard

Slack Bot integration with FunRetro

Open JavierLight opened this issue 8 years ago • 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.

JavierLight avatar Nov 06 '17 09:11 JavierLight

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.

glauberramos avatar Nov 06 '17 17:11 glauberramos

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 :)

JavierLight avatar Nov 07 '17 13:11 JavierLight

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?

glauberramos avatar Nov 07 '17 14:11 glauberramos

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

JavierLight avatar Nov 07 '17 15:11 JavierLight

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 avatar Nov 07 '17 16:11 glauberramos

@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

Roshanjossey avatar Nov 07 '17 19:11 Roshanjossey

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.

tinoromero avatar Dec 19 '17 22:12 tinoromero

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 avatar Dec 19 '17 22:12 glauberramos

@glauberramos sure, I'll give it a shot.

tinoromero avatar Dec 20 '17 18:12 tinoromero

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.

tinoromero avatar Dec 26 '17 18:12 tinoromero

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

Roshanjossey avatar Dec 26 '17 18:12 Roshanjossey

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?

tinoromero avatar Dec 26 '17 20:12 tinoromero

Yeah @juventinoromero, that's the method we need to implement.

glauberramos avatar Dec 26 '17 20:12 glauberramos

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

tinoromero avatar Dec 28 '17 01:12 tinoromero

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 avatar Dec 28 '17 16:12 glauberramos

@glauberramos, it does! Thanks :smile:

tinoromero avatar Dec 28 '17 18:12 tinoromero

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?

tinoromero avatar Dec 30 '17 22:12 tinoromero

@juventinoromero the code worked perfectly 💃, I already merged your pull request, thanks for that. @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 avatar Jan 07 '18 23:01 glauberramos

@glauberramos great news! 🕺 Thanks!

tinoromero avatar Jan 08 '18 00:01 tinoromero

You guys are amazing. Thank you very much for your time and effort!!

2018-01-08 1:07 GMT+01:00 Juventino Romero [email protected]:

@glauberramos https://github.com/glauberramos great news! 🕺 Thanks!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/funretro/distributed/issues/231#issuecomment-355864421, or mute the thread https://github.com/notifications/unsubscribe-auth/AGtym9BYlI2WhGVNPY2UhMTKkzO3XuQjks5tIVxOgaJpZM4QS615 .

JavierLight avatar Jan 08 '18 10:01 JavierLight

What is the status of this. I want to help.

This is what I get when I access that endpoint.

image

Kiri23 avatar Feb 04 '18 18:02 Kiri23

I think this is on hold, if you want to implement the slack plugin please go ahead @Kiri23

glauberramos avatar Feb 06 '18 13:02 glauberramos

But how do I do it with vanilla JavaScript because you don’t have a server/backend like for instance Node.js.

El 02/06/2018, a la(s) 9:02 a. m., Glauber Ramos <[email protected]mailto:[email protected]> escribió:

I think this is on hold, if you want to implement the slack plugin please go ahead @Kiri23https://github.com/kiri23

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/funretro/distributed/issues/231#issuecomment-363415303, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ARMYAAOLpCxoS9mJGxT5KR8jCllR_tzCks5tSE1wgaJpZM4QS615.

Kiri23 avatar Feb 06 '18 17:02 Kiri23

Firebase functions 💃

glauberramos avatar Feb 06 '18 17:02 glauberramos

And what version of angular is this project build from. Is this angular 1 ?

El 02/06/2018, a la(s) 1:41 p. m., Glauber Ramos <[email protected]mailto:[email protected]> escribió:

Firebase functions 💃

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/funretro/distributed/issues/231#issuecomment-363504098, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ARMYACx2EbMtsgwiXHeKq2BsO6B84uiYks5tSI7cgaJpZM4QS615.

Kiri23 avatar Feb 06 '18 17:02 Kiri23

You can check that on package.json

glauberramos avatar Feb 06 '18 17:02 glauberramos