A streaming client for flowdock flows
A node module for streaming flowdock flows. NOTE: for the older API, check version 0.1.3.
npm install flowdock-stream
var FlowdockStream = require'flowdock-stream';var org = 'organization';var flows = 'flow' 'another';var apikey = 'personal-apikey';var flowdockStream = FlowdockStreamcreateClientorg flows apikey;flowdockStreamon'ready'console.log'flowdockStream is ready, flows:\r\n' flowdockStreamflows;;flowdockStreamon'data'var sourceFlow = flowdockStreamflowsdataflow;if dataevent === 'message'var from = datauser ? sourceFlowusersdatauser : null;console.log'a message from' from datacontent;else if dataevent === 'join'var flowName = sourceFlowname;flowdockStreamgetUsersflowNameif err return flowdockStreamemit'error' err;sourceFlowusers = users;flowdockStreamsendflowName 'Hello ' + usersdatauser;;;flowdockStreamon'error'throw err;;
A stream is created with the only exported function as follows:
FlowdockStream.createClient( organization, flows, apikey )
flowsargument can be either a string (for a sinlge flow) or an array (for multiple flows)
readyevent once the stream is about to start emitting data and the
flowsproperty has been set
The stream itself is a readable node.js stream in object-mode (each
data-event holds a complete object), but added are a couple of methods for convenience:
flowdockStream.getFlows( callback )
flowdockStream.getUsers( flow, callback )
flowdockStream.send( flow, message, [commentToId], [callback] )
flow(you can pick the flow-name from the flows-object by the id in an event-callback, see the example). Optionally you can pass an message-id as the third argument to send the message as a comment to a previous message. Also takes an optional callback which is passed to the underlying request module.