Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   The Blue Alliance (http://www.chiefdelphi.com/forums/forumdisplay.php?f=174)
-   -   [TBA]: TBA to Slack integration (http://www.chiefdelphi.com/forums/showthread.php?t=146508)

mikhail 31-03-2016 12:52

[TBA]: TBA to Slack integration
 
I wonder if anyone already succeeded to integrate The Blue Alliance with Slack (http://slack.com/). Our team 3130 is using Slack for all teamwork communications as well as for keeping in touch with parents and all other fans of the team. I'd expect some other teams might do the same. So my thinking is it would be great if there was a way to have a channel for TBA updates into Slack that everyone on the team could monitor and didn't have to poll the TBA servers individually.

I can see TBA provides an API for push notifications via webhooks. The Slack can receive webhook POST requests as well. The only problem is how to reshape TBA's payload into Slack's format (https://api.slack.com/incoming-webhooks). Technically it should be possible to do either on TBA side or Slack side or on an intermediate http server. Have anyone tried any of these opportunities yet? Thank you.

joelg236 31-03-2016 13:04

Re: [TBA]: TBA to Slack integration
 
If nobody has done this already, I'd totally be willing to help do it. Would be pretty awesome to have. We run a #live channel for watching streams and whatnot, so a "favorite teams" bot would be a perfect addition.

plnyyanks 31-03-2016 13:19

Re: [TBA]: TBA to Slack integration
 
I love this idea! As the original author of TBA webhooks, it's awesome to see people come up with cool uses for them.

I think you're going to have to build your own server somehow to receive TBA webhooks and post to slack. I say so because TBA webhooks just return the raw data associated with an event. It does not return a human-readable string about what happened. It'll be best to let end users (you) decide how you want your messages to read and to format them yourself.

That being said, I'll definitely watch what you do with interest, and hope that you open source it!

Eugene Fang 31-03-2016 14:02

Re: [TBA]: TBA to Slack integration
 
Quote:

Originally Posted by plnyyanks (Post 1565751)
I think you're going to have to build your own server somehow to receive TBA webhooks and post to slack. I say so because TBA webhooks just return the raw data associated with an event. It does not return a human-readable string about what happened. It'll be best to let end users (you) decide how you want your messages to read and to format them yourself.

I'm pretty the custom server could fully run within the free quota of Google App Engine. Just a thought.

joelg236 31-03-2016 14:21

Re: [TBA]: TBA to Slack integration
 
Quote:

Originally Posted by Eugene Fang (Post 1565766)
I'm pretty the custom server could fully run within the free quota of Google App Engine. Just a thought.

Or heroku, rackspace, etc. very easily. Depends if you wanted to offer this as a public service or ask teams to deploy it themselves (easy enough).

mikhail 01-04-2016 00:30

Re: [TBA]: TBA to Slack integration
 
This is so cool. Thanks for responses guys! I went ahead and created an account on Google App Engine for myself. They gave me 60 days of free trial - plenty for this season. Then we will see. Now I'm thinking what programming language to use. I'd guess following TBA it would be Python, right? Shall we create a project on GitHub? Of course it must be open source, not a tiny doubt about that.

joelg236 01-04-2016 10:16

Re: [TBA]: TBA to Slack integration
 
Quote:

Originally Posted by mikhail (Post 1565956)
This is so cool. Thanks for responses guys! I went ahead and created an account on Google App Engine for myself. They gave me 60 days of free trial - plenty for this season. Then we will see. Now I'm thinking what programming language to use. I'd guess following TBA it would be Python, right? Shall we create a project on GitHub? Of course it must be open source, not a tiny doubt about that.

Can I suggest a simple nodejs app that ingests TBA through this and serves slack JSON?

example

mikhail 01-04-2016 12:33

Re: [TBA]: TBA to Slack integration
 
Quote:

Originally Posted by joelg236 (Post 1566021)
Can I suggest a simple nodejs app that ingests TBA through this and serves slack JSON?

example

That's a wonderful library for polling TBA with GET requests. Must be a really powerful tool to run in a browser. What I was thinking of was a library to receive and parse POST requests from TBA so then the data could be recomposed into another POST and sent to Slack's webhook.

plnyyanks 01-04-2016 12:56

Re: [TBA]: TBA to Slack integration
 
Quote:

Originally Posted by mikhail (Post 1565956)
This is so cool. Thanks for responses guys! I went ahead and created an account on Google App Engine for myself. They gave me 60 days of free trial - plenty for this season. Then we will see. Now I'm thinking what programming language to use. I'd guess following TBA it would be Python, right? Shall we create a project on GitHub? Of course it must be open source, not a tiny doubt about that.

App Engine actually has a free tier, and you shouldn't need any more resources that that. Python works nicely on App Engine, so that's a perfectly fine choice (other GAE choices are Java, Go, and PHP)

Quote:

Originally Posted by joelg236 (Post 1566021)
Can I suggest a simple nodejs app that ingests TBA through this and serves slack JSON?

example

I'm not sure that library works if webhooks are used. The server wouldn't actually poll the TBA API, the flow would go something like this:

TBA ---(webhook)---> GAE (process, format) -----(Slack Message)---> Slack

joelg236 01-04-2016 12:57

Re: [TBA]: TBA to Slack integration
 
Quote:

Originally Posted by plnyyanks (Post 1566094)
App Engine actually has a free tier, and you shouldn't need any more resources that that. Python works nicely on App Engine, so that's a perfectly fine choice (other GAE choices are Java, Go, and PHP)



I'm not sure that library works if webhooks are used. The server wouldn't actually poll the TBA API, the flow would go something like this:

TBA ---(webhook)---> GAE (process, format) -----(Slack Message)---> Slack

You're totally right, I had it mixed up in my head. Makes sense.

mikhail 05-04-2016 00:41

Re: [TBA]: TBA to Slack integration
 
Update:
I finally succeeded connecting the two webhooks: from TBA to Slack. Yay! It's a -nasty hack- convoluted Python script running on Google Apps. So far it is very simplistic, basically just stripping JSON formatting for a couple of message types. I can't open-source it yet because all the URLs and secrets are hard coded into the script. I'll see how it works this upcoming weekend then will try to rewrite it in a more open-source-able form (after I'm done with my taxes as well). Stay tuned.

mikhail 09-05-2016 23:45

Re: [TBA]: TBA to Slack integration
 
Alright. Sorry for the delay, our team 3130 happened to win its second regional and had to go to the world champs. So all our resources were taken by the preps. Now as the competitions season is over I managed to scratch some time to publish our code onto GitHub. Here it is.

https://github.com/team3130/TBA-push-to-Slack/

That's a very basic example we tested in our Slack team. So far only "Upcoming Match" and "Match Score" notifications are implemented. And even those are very basic.

I'd love to hear suggestions how to make the project more collaborative so others could contribute. For the starters the major conflict I already can see would be that if this project grows further everyone will want their own formatting for messages. For the meantime I have no idea how to handle that. Please chime in.


All times are GMT -5. The time now is 19:44.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi