flowdock / hubot-flowdock

Flowdock adapter for Hubot chat bot
94 stars 60 forks source link

Add flowdock "activity" to the hubot adapter #75

Closed ojacques closed 9 years ago

ojacques commented 9 years ago

I would like to start implementing "activity" type of messages, as per this API doc https://www.flowdock.com/api/message-types#/activity

The first use case is to create activities for Gerrit events coming from Hubot Gerrit script - https://github.com/github/hubot-scripts/blob/master/src/scripts/gerrit.coffee

At a first look, I need to modify both.

Any recommendation on implementing this on the flowdock adapter? I'd like to do it right.

Mumakil commented 9 years ago

You don't really need the flowdock adapter for this, since posting to the activity api requires just a source token and a simple json payload. We've done something similar with hubot-deploy-status so you can look at that repo for starters.

https://github.com/flowdock/hubot-deploy-status/blob/master/src/cron.coffee runs a cron job to query github for deployment events for configured repositories and checks if the deployments are up to date with the master branch. It has an adapter configuration parameter, which can be used to tell it to use a specific formatter and api endpoint for reporting the results. There's a very simple default adapter at https://github.com/flowdock/hubot-deploy-status/blob/master/src/adapters/default.coffee that just uses hubot to send a chat message, but the flowdock adapter at https://github.com/flowdock/hubot-deploy-status/blob/master/src/adapters/flowdock.coffee is probably what you're looking for: it formats a Flowdock specific result and posts it to the activities api.

That way any hubot users can use the script in the generic form, but the richer Flowdock api can also be leveraged.

ojacques commented 9 years ago

Thanks @Mumakil !

Thanks for pointing to the deploy-status example, very instructive.

From what I understand, I will have to duplicate the adapters/flowdock.coffee everytime I need to have an hubot script which posts to the activities API.

Wouldn't it make sense to include the activity FD API as part of the main flowdock adapter? Maybe hubot adapters don't even allow that by design...

Mumakil commented 9 years ago

We could maybe make a wrapper for it in the node-flowdock package. The reason why I'm hesitant to add it here is that:

ojacques commented 9 years ago

Makes a lot of sense. Thanks for all your support! :+1: Closing this one.