pipes-digital / pipes

Repository for Pipes
https://pipes.digital
GNU Affero General Public License v3.0
261 stars 21 forks source link

Does pipes work with webhooks? #6

Closed jean closed 7 years ago

jean commented 7 years ago

I'd like to integrate with github in the manner described here: https://flow.microsoft.com/en-us/documentation/customapi-webhooks/

onli commented 7 years ago

No, there is no webhook integration. Pipes just returns a RSS feed.

You do want to create a pipe that sends a webhook as soon as the pipe fetches a new element?

jean commented 7 years ago

I'd like to install a webhook in my github account: Creating Webhooks. When creating a webhook, you set it to fire upon specific events. That basically means that when that event occurs, github will do an HTTP POST to the endpoint configured in the webhook. That's basically the opposite to a feed, in that it's push, not pull. So the ingestion point for pipes would be receiving a POST with a JSON payload, instead of polling for new items in an Atom feed. A workaround would be a small server that receives webhook posts and queues them up as an Atom feed.

onli commented 7 years ago

Okay. This direction I could imagine for Pipes. We would need a new block that configures a webhook endpoint, that endpoint would transform the webhook into an RSS feed, the payload becomes the content element.

I will have to play a bit with that idea before being able to promise that it will come as a feature. In the meantime your workaround sounds good - if you have another service that translates a webhook to Atom or RSS you could use that feed as a pipe input.

onli commented 7 years ago

@jean Pipes now works with webhooks. I added a new webhook block, which will show you your webhook endpoint. You can then configure Github to POST to that endpoint, and pipes will create an RSS feed for you.

See https://www.pipes.digital/docs#webhookblock for more info.

I admit, I mainly implemented it because it is too cool a feature not to have ;) Would be great if you could report back whether it works for you.

jean commented 7 years ago

I'm afraid I didn't have time again, but I will come back to this eventually. I got a bit tied into a knot getting the webhook created at github.

Something else prevented me too: I realised (again?) that github publishes atom feeds of commits, so I created some pipes that take the atom feed, filter it, duplicate it, extract extract extract three elements, builds a feed, and outputs. I then feed this to Zapier to create Trello cards. Now Zapier has far fewer events to deal with, and I come in under quota. Yay! Pipes is awesome.

giummy commented 7 years ago

@onli please, could you publish a working example of webhook usage? I make a POST with as payload of my http request to https://www.pipes.digital/hook/d1396dfa72, but the corresponding GET gives no update to the [Webhook] block.

onli commented 7 years ago

@giummy I'm currently activating the update that allows public pipes. After that is done I will create one with a webhook in it.

Edit: Short confirmation, something is wrong. The POST to the hook arrives in the database, but somehow is not accessible afterwards. I'm on it.

onli commented 7 years ago

@giummy It should work now. That was actually a really strange bug. Everything worked, just not on the production platform. There this happened:

sqlite> select * from hooks WHERE id = 3;
3|A fifth POST to ec2fa826f9|ec2fa826f9|2017-08-01 15:14:49
sqlite> select * from hooks WHERE blockid LIKE 'ec2fa826f9';
sqlite>

Despite the blockid being set visually properly, it was just not selectable. Though when copying the database into my dev environment, it worked.

The solution was to add a CAST(x AS TEXT) around the blockid.

My example pipe with a working webhook block is on https://www.pipes.digital/pipes, visit https://www.pipes.digital/editor?fork=y1N5Pa9g to fork it to your account.

Thanks for reporting this!