Skip to content
This repository has been archived by the owner on Feb 20, 2020. It is now read-only.

Post major events within a group to slack #130

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

Connoropolous
Copy link
Contributor

Notes:

  • need to replace hard coded 'root_url' with something that will always represent the front end routing

screen shot 2016-03-18 at 9 38 39 pm

@@ -0,0 +1,50 @@
Webhooks::Slack::Base = Struct.new(:event) do

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sure looks familiar :P

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally, I spun this off from loomio into metamaps land first, and then over to here. Absolutely worth noting that @gdpelican wrote a lot of this originally and should get a lot of the credit :)

@ahdinosaur
Copy link
Member

(((o(゚▽゚)o)))

thanks @Connoropolous @gdpelican, this is great. 👍

@data-doge
Copy link
Contributor

omg thank yall so much ! <3 <3 <3

i'm in the depths of a fellowship application so won't have the chance to review until the end of sunday

@derekrazo
Copy link
Contributor

Connor this is so amazing. I will be getting on a plane just now, but will
send the requested material very soon.

Best,

Derek

On Fri, Mar 18, 2016 at 11:51 AM, Connor Turland [email protected]
wrote:

Notes:

  • need a legit 48x48 logo image hosted online that works nicely for
    this, and set icon_url to that
  • need to replace hard coded 'root_url' with something that will
    always represent the front end routing
  • how are the messages?

[image: screen shot 2016-03-18 at 9 38 39 pm]

https://cloud.githubusercontent.com/assets/1409121/13875629/29e4e660-ed53-11e5-85de-e2fe340a384a.png

You can view, comment on, or merge this pull request online at:

#130
Commit Summary

  • everything but final wording/formatting
  • finish up styling and architecture
  • remove routing, unneeded

File Changes

Patch Links:


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#130

@derekrazo
Copy link
Contributor

I've also just share our activity email content with you! It lists major
events and also messages associated with them. So feel free to use that,
and then if there's any more questions I can answer here.

On Sat, Mar 19, 2016 at 2:25 PM, Derek Razo [email protected] wrote:

Connor this is so amazing. I will be getting on a plane just now, but will
send the requested material very soon.

Best,

Derek

On Fri, Mar 18, 2016 at 11:51 AM, Connor Turland <[email protected]

wrote:

Notes:

  • need a legit 48x48 logo image hosted online that works nicely for
    this, and set icon_url to that
  • need to replace hard coded 'root_url' with something that will
    always represent the front end routing
  • how are the messages?

[image: screen shot 2016-03-18 at 9 38 39 pm]

https://cloud.githubusercontent.com/assets/1409121/13875629/29e4e660-ed53-11e5-85de-e2fe340a384a.png

You can view, comment on, or merge this pull request online at:

#130
Commit Summary

  • everything but final wording/formatting
  • finish up styling and architecture
  • remove routing, unneeded

File Changes

Patch Links:


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#130

validates_inclusion_of :kind, :in => KINDS
validates_presence_of :eventable

acts_as_sequenced scope: :group_id, column: :sequence_id, skip: lambda {|e| e.group.nil? || e.group_id.nil? }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

future self: look

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gdpelican

connor and eugene want to know what is this? and do we need it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Er, we use this to say events have a sequence_id, which is a better way to order things (in a discussion say) than by ID or created_at. You shouldn't need it for webhook stuff.

end

def url_root
ENV["ROOT_URL"] + "/#/"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we will need to set this on the heroku app where the job worker will be running. should look like
ROOT_URL=http://beta.cobudget.co

@Connoropolous
Copy link
Contributor Author

@data-doge @derekrazo this is ready for review again now :)

@derekrazo
Copy link
Contributor

Thanks x2000 for this Connor - you are amazing! @eugene will ping you with
more sometime soonish. Just finishing up some urgent stuff and wanted to
let you know we saw this and discussed :)

On Sun, Mar 27, 2016 at 10:10 PM, Connor Turland [email protected]
wrote:

@data-doge https://github.com/data-doge @derekrazo
https://github.com/derekrazo this is ready for review again now :)


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#130 (comment)

@Connoropolous
Copy link
Contributor Author

Connoropolous commented Mar 30, 2016 via email

@jessykate
Copy link
Member

Hi all, this looks like it was a great PR! Is there a reason it didn't get merged? @Connoropolous what configuration would be needed (on an app-wide or per-group level) to make this functional?

@Connoropolous
Copy link
Contributor Author

@jessykate :) it was, I think, just a simple lack of time and will at the time.

it could be set up to work as is, with some configuration on the app level, but I believe its the case that there's no UI for it, so adding particular configurations for particular groups has to be done through the interactive ruby console, which is how I was doing it. this PR could be expanded/combined with another one, without too much difficulty, that made it possible to configure things on a group basis from the UI

@Connoropolous
Copy link
Contributor Author

Connoropolous commented Mar 21, 2017

for the app, it needs to be configured with two environment variables

this should be set to point to a 48x48 px image
SLACK_ICON_URL=https://someimageurl.com/picture.png
we will need to set this on the heroku app where the job worker will be running. should look like
ROOT_URL=http://beta.cobudget.co

@jessykate
Copy link
Member

nice!! i'd say let's split the UI into another ticket and focus on getting this merged, since as you say it's functional as-is. are you keen/have bandwidth to pull in the latest code we've been working on and fix the merge conflicts? (no worries if not, just LMK so i know if we should put our attention to it!)

you mentioned you were doing this manually yourself-- are you running your own instance of cobudget? 😍

@Connoropolous
Copy link
Contributor Author

Connoropolous commented Mar 21, 2017

Just resolved the merge conflicts here on github, didn't seem to be anything that would break, but I think from here I'd say take it over if you can, and give it a test before deployment. Here's what to do:
set up the .env file to have

SLACK_ICON_URL=https://pbs.twimg.com/profile_images/535182261553876992/MV2TWTgd_400x400.png
ROOT_URL=http://localhost:3000

or whatever your local development frontend instance is running at, for ROOT_URL

then grab a webhook from a slack team you're part of.
run
rails c to start to interactive ruby, then

group = Group.find(your-group-id)
Webhook.create!(hookable: group, kind: 'slack', uri: 'your-webhook-uri', event_types: ['bucket_created', 'bucket_moved_to_funding', 'bucket_funded'])

You'll have to be running the rake jobs:work task in the background.
Then access the UI and try out the three things that trigger events :)

@Connoropolous
Copy link
Contributor Author

@jessykate no, I'm not running my own instance of cobudget atm, I just meant while I was doing development :)

@jessykate
Copy link
Member

Thanks @Connoropolous! I will put this on my list for next week.

@Connoropolous
Copy link
Contributor Author

My pleasure. I take it cobudget is still in active use by you and some projects you work on :)

@jessykate
Copy link
Member

@Connoropolous I believe I've set everything up... The rake task is running and I can see that it's receiving and processing the tasks, but nothing hits the slack channel. Any thoughts? (posted this on slack but am not sure if you are receiving notifications there :)).

here's the webhook object:

1__bundle_exec_rails_console__ruby_

and here's the rake task output i see when an event gets triggered:

1__jessykate_random____code_greaterthan_cobudget_cobudget-api__zsh_

thanks!

@Connoropolous
Copy link
Contributor Author

@jessykate I just remembered your comment! sorry it took me a while, too many balls in the air.

what comes to mind for debugging this scenario, is inspecting the result of the http post request. It may show an error. This could be related to slack updating the structure of the data since I wrote this?

@gdpelican
Copy link
Contributor

I can confirm that slack hasn't updated their API, as we're still using this code in prod for our slack webhooks in Loomio.

That model LGTM, JessyKate... so I think you're interested in digging into webhook_service.rb#4, where we post to the endpoint, and seeing if that gets hit and if so, what the response is.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants