WEB HOOKS
and the
Programmable World of Tomorrow
Jeff Lindsay
introduction
talk about this idiom, show examples, share ideas, explain significance
how many are familiar with this idiom?
Web Service
internetz
User
for those that don’t know: a story
Web Service
Hi, I’m Twickr,
a new web service.
internetz
User
both have been around longer, but the point is rest simpler..
in fact, it’s almost described as “using HTTP properly”
but not until it got a name could it be used in discourse to make it popular
REST
Hooks
rest and web hooks are two sides of the same coin
they complement each other in ways i’ll get to later
but i just want to give this pattern a name, and start associating some ideas with it
Push
Pipes
Plugins
talk is split into three sections
ways to look at the use of web hooks
icons will hopefully make more sense as i talk about them
Push
let’s get started with push
people are starting to talk about push in the context of web content
because of feeds. or rather, the success of feeds
it started with blog feeds, then comment feeds...
then soon exploded into twitter feeds, photo feeds, activity feeds, event feeds, bookmark feeds
even feeds of feeds
then soon exploded into twitter feeds, photo feeds, activity feeds, event feeds, bookmark feeds
even feeds of feeds
then soon exploded into twitter feeds, photo feeds, activity feeds, event feeds, bookmark feeds
even feeds of feeds
then soon exploded into twitter feeds, photo feeds, activity feeds, event feeds, bookmark feeds
even feeds of feeds
then soon exploded into twitter feeds, photo feeds, activity feeds, event feeds, bookmark feeds
even feeds of feeds
then soon exploded into twitter feeds, photo feeds, activity feeds, event feeds, bookmark feeds
even feeds of feeds
then soon exploded into twitter feeds, photo feeds, activity feeds, event feeds, bookmark feeds
even feeds of feeds
it makes you think of feeds like in the telecom world
then it gives it to us. and we do this over and over.
are we there yet? are we there yet?
?
feeds made sense in a world where feed readers ran on
desktops that couldn’t be pushed to over http
?
of course, now we have other web applications consuming feeds and it doesn’t make sense
even our feed readers have become web applications
evan and kellan gave a great talk about this, and their proposed solution: xmpp
i have a condensed version of this talk. the slides speak for themselves
(aka XMPP)
they have a great point. polling sucks, and xmpp is a pretty good solution for data streams
but it’s kind of heavy weight. it does a lot and makes a decently complex little system.
luckily it’s not *that* hard to use with today’s library support
“One solution that occurred to me at the time was to build a simple callback system over HTTP.
This would fall comfortably between full polling and full persistent publish/subscribe.”
i think you’re onto something joshua.
i just don’t know about the name PIMP (or even Push RSS really).
it *is* a nice place between polling and xmpp pubsub
evan and kellan did point out there are extremes when it comes to data streams.
most data streams will probably fall somewhere in between,
but i do think xmpp is perfect for the fast and furious end
microformats
i’m a fan of microformats. not just in what they do, but how they do it.
very ground up, grassroots... take existing popular use-patterns and make it a convention.
like web hooks, microformats can be viewed as an alternative to something: xml+rdf
xml+rdf vs microformats
“Here's a new language we want you to learn,
and now you need to output these additional
files on your server. It's a hassle.
(Microformats) lower the barrier to entry.”
tantek is a big microformats evangelist. he says....
so i told him about web hooks. “what are they?” “push over http”
“how are they diff than xmpp?” “they’re a lightweight alternative”
xmpp vs web hooks
“Good. XMPP needs a competitor.”
he says...
this was encouraging. i mean, when tantek talks, you listen...
if for no other reason than
started spreading the word as “web hooks” and it started popping up places.
this is a standard for discovering and subscribing to content changes.
they use both web hooks and xmpp, which is a good sign.
good idea, but standard specs alone don’t get very far
gnip though. let me tell you about gnip...
if we could just figure out what they do...
ah, no, they’re on to something
but they do a lot in several dimensions, so its hard to explain all that they do.
notice they mention web hooks though... so i gotta figure out what they do.
Source Destination
Protocol + Mechanism Protocol + Mechanism
Format Format
Web Hooks Web Hooks
RSS RSS
XMPP XMPP
Atom Atom
XML XML
REST REST
Publisher Consumer
ok. so here’s what i found out. they’re an adaptor for data streams,
letting publishers and consumers choose their format, protocol, and mechanism of choice
various formats, polling or push using web hooks or xmpp (soon).
Source
Protocol + Mechanism Protocol + Mechanism
Format Format
Web Hooks Web Hooks
RSS RSS
XMPP XMPP
Atom Atom
XML XML
REST REST
Publisher Consumer
so for example, i want a digg data stream
Source
Protocol + Mechanism Protocol + Mechanism
Format Format
Web Hooks Web Hooks
RSS RSS
XMPP XMPP
Atom Atom
XML XML
REST REST
Publisher Consumer
they provide in rss over rest, which means polling
Source
Protocol + Mechanism Protocol + Mechanism
Format Format
Web Hooks Web Hooks
RSS RSS
XMPP XMPP
Atom Atom
XML XML
REST REST
Publisher Consumer
but i want web hooks with an atom payload.
gnip makes it happen
Protocol + Mechanism Protocol + Mechanism
Format Format
Web Hooks Web Hooks
RSS RSS
XMPP XMPP
Atom Atom
XML XML
REST REST
Publisher Consumer
same thing if twitter provides xmpp notifications, but i have rss polling infrastructure...
gnip makes it happen
Protocol + Mechanism Protocol + Mechanism
Format Format
Web Hooks Web Hooks
RSS RSS
XMPP XMPP
Atom Atom
XML XML
REST REST
Publisher Consumer
cases like with friendfeed (which doesn’t actually work with fb)
say fb provides atom over rest, but friendfeed doesn’t find that efficient... they want xmpp
gnip
Protocol + Mechanism Protocol + Mechanism
Format Format
Web Hooks Web Hooks
RSS RSS
XMPP XMPP
Atom Atom
XML XML
REST REST
Publisher Consumer
even something as redundant as polling atom on both ends,
gnip offloads the polling stress from facebook (and adds filters, etc)
XMPP is ideal when needed,
but Web Hooks generally do the job.
as far as xmpp vs web hooks, i think they both have their place.
But push is not the point.
so far, push has been about pushing content. this is not that interesting to me.
i like functionality. and as simple as web hooks are, they have something xmpp doesn’t:
simple code triggering
there once was a command line
nav filesystem, launch apps, scripting environment.
but it had an extra something special: pipes. letting you combine applications
Input Output
Program
all from a bit of infrastructure involving input and output
STDIN STDOUT
Program
STDERR
stdin, stdout were available to reroute wherever the user wanted
most common use was chaining commands together: piping
xargs
wget
echo
mail
grep
wc
cat
so you had all these simple little programs, that might not even be useful alone
cat
xargs
wget
echo
mail
grep
wc
string them together...
cat grep mail
xargs
wget
echo
wc
and you have something more useful than the sum of the parts
Write programs that do one thing and do it well.
Write programs to work together.
Write programs that handle text streams,
because that is a universal interface.
this helped put forth the unix philosophy
STDIN
Program
but it doesn’t work without the output. it just breaks.
API
Web App
unfortunately that’s how the web is today.
we can talk to web apps, but they really can’t talk to us. or anything else really.
API Events
Web App
it’s not that they can’t, they just don’t. we need to start placing event hooks in.
REST Hooks
Web App
those roles are best played by mechanisms that use the protocol the web is built on
cat grep mail
Basecamp
so we want to combine web applications like we can CLI programs.
get more than the sum of the parts.
web hooks open up this possibility, but need like APIs, need to be implemented
Basecamp
Project finished
Todo completed
Milestone created
Contact added
File uploaded
Basecamp
My handler
http://example.com/handler
users can write handlers that are just web scripts.
they have a url, and thats what you give basecamp
Basecamp
My handler
http://example.com/handler
it’s code. it can do anything from there.
integrate with other services, make a phone call, order pizza, whatever
Todos
Basecamp
for example, all these apps share data about todos. they each have respective specialized talents,
but all work with todos. by putting hooks on todo CRUD,
you can use their apis to keep them synced pretty well. magically. real-time.
Code as glue
based on the idea that web urls can run code. and code can do anything.
when i first thought about this, cheap PHP hosting was all over, but it could be even simpler.
there are paste bins like this one. made to share formatted code with people over IRC or email
put in some code you want to share or ask a question about
Basecamp
Project finished
http://pastie.org/run/24576
for example, basecamp. now when you finish a project, everybody meets for shots in the break room.
just hit a button, write code, hit save, share the url. it’s javascript
obviously app engine, although it’s a little more involved than appjet for quick handlers.
but it is an option for python.
and there are ruby/rails hosts like heroku
one thing i’ve been working on is an extension to integrate these ideas.
Hey, there’s an
event hook here!
by detecting some markup in a page, it discovers hooks.
like say for new photos from contacts.
you want to do something when that happens, click it
Save
and write some code. hit save, it posts to AppJet (or wherever),
registers the handler (assuming a standard protocol), and done. all inline.
go back and change the code.
Real world examples
but these are all mockups and what-ifs...
there is a world of web hooks already evolving...
i started by exposing svn hooks as web hooks in devjavu
i talked about web hooks enough using pbwiki as an example,
their mysterious cto decided to implement them
“Building projects with web hooks in
mind lets me keep the core Lighthouse
source focused, while external
services live in their own libraries.”
--Rick Olson
from there the idea silently spread to other rails guys.
rick olson used them in lighthouse
“We implemented web hooks a while
ago and people have been building all
sorts of unexpected stuff on top of it.”
--Tobias Lütke
tobias used them in shopify. i’m told he’s revamping their api to have more hooks
and back to github. they were so successful with the adhoc integration, they formalized it.
but in the best way! using their existing web hook infrastructure.
they just have modules running in a separate but local web service.
in fact, that lets them open source it. letting people fork, write new handlers, and push back.
this is probably going to be the standard model of service integration.
and a great example of services integrated with github, besides lighthouse, is runcoderun.
they run your regression tests for you. continuous integration in the sky. love it.
they sign you up automatically if you put their hook in github.
then there’s martyn and andy. two guys in the uk that love web hooks.
they built this thing called spaghetti junction at a hackday. it involved into...
switchub. i REALLY love this. i knew this sort of thing would emerge, but i didn’t think it would happen
until web hooks were more popular. kind of like the pastinbin code runner, they let you create hook
inputs with urls to put in apps that you can route to various output handlers: email, irc, etc
my example switchboard. this kind of feels like gnip, only more focused and more about web hooks.
so i like it lots.
opening handlers up like github. anybody can write handlers soon.
working with them a little to make it real awesome.
for example, i suggested rss as an input, but that would require polling. well distribute it!
let somebody like rssfwd implement hooks and use them.
wow, what other services could you build around switchub?
switchub is more of how i envisioned piping on the web.
yahoo pipes was a great experiment, but it’s not real pipes. no integration. only aggregation.
flip it around and wire them together however you like. totally cool.
and of course i mentioned paypal. but i should mention, web hooks make so much sense
for paypal... they’re not so much about pushing content, but INTEGRATING. that’s what
web hooks are great for, even though they can be used for content push.
jott is another example of a web hook implementer that doesn’t know it.
they parse voice over the phone and do stuff with it, like post to twitter, etc
they do it with “Links”... which are just hooks. they post to a script that does something with
the parsed text. really cool for todos.
User jotts to The message is Message is sent via Jott reads back the User receives
a Jott Link converted HTTP Post to a response and sends information back
into text web page it via SMS & SMTP
here’s their diagram. totally web hooks.
so, thinking back to switchub, and like jott, there’s a lot of cool ideas for something to web
hook services. I made mailhook to parse incoming email and trigger scripts to handle it.
very useful.
GAE community made one because GAE doesn’t have a way to accept email.
web hooks were the obvious solution.
rick olson has an open source non-hosted ruby version that will do xmpp.
he uses it for lighthouse.
but smtp2web is interesting because it was made because of the limitations of GAE...
in fact a lot of people made these kinds of “micro webservices” to do simple things GAE
didn’t do.
http://movq.net
here’s a couple from a site i found. they have a cool cron service ... should be useful in the web hooks
ecosystem
making things more web friendly...
working with lisa dussault to make a IMAP to REST bridge...
this makes working with email mailboxes way easier in the context of the web
it’s neat to see it in netnewswire. looks like mail.app
point is to make more protocols easier to work with from web scripts in fairly limited
environments... because there will be more of them as the cloud grows
Write services that do one thing and do it well.
Write services to work together.
Write services that interact with HTTP,
because that is simple + ubiquitous
...and it’s already in your stack.
but these micro webservices are like the tiny CLI programs that aren’t very useful by
themselves. but they need a means to interact with other apps, and web hooks have been the
obvious solution. so i’d like to start pushing these tenets, similar to the unix philosophy
jon udell talks about websites as data sources that can be reused and remixed
today that idea isn’t very novel
“a new programming paradigm
that takes the whole Internet
as its platform”
he envisions the Internet (and I’ll say the web) as a programming paradigm. i’d say also an OS, but
that’s for another time. but it won’t be true until apps are composable and easily integratable.
tangent: this is a neat find. was on reddit. andreessen proposing IMG tag.
people fought it, said it needed to be more generalized.
he just put it on mosaic and that was that
almost called this section Platforms.
platforms are really cool. we all love them.
i LOVE them, so fb platform was really cool.
asked a friend how it worked. he said “web hooks”
sure enough, this looks like web hooks to me. as long as it’s http, calling out... but then using the
results in their app? thats different...
in fact a few people have used web hooks for plugins. dabble is a great example.
they do online databased for people that use excel as a database.
“Dabble plugins allow Dabble applications to create new, derived fields by calling out
to external HTTP-accessible applications. This solves the problem of safely enabling
extension of a centrally-located hosted application, in that, while you’re writing code
to extend and enhance the behavior of a Dabble application, your code never
actually runs inside Dabble.”
[General]
Name = Amazon Sales Rank
[Sales Rank by ISBN]
URL = http://chadfowler.com/dabble/amazon_sales_rank.cgi
Input = Text
Output = Number
only they have an extra layer for meta data. but that’s a cool pattern.
“If you’ve used a UNIX-based operating system, you’re probably
familiar with the notion of pipes. The output of one program is
piped into the input of another, creating a filter chain. This is
conceptually the same as the way Dabble’s plugin IO works.
Nice and simple.”
of course, they compare it to pipes. the simplicity. the natural fit of it.
of course, i think they should have web hooks for all their standard CRUD events...
this way their database apps can integrate (like PayPal) with the rest of your workflow
in fact, all these “app platforms” like coghead and salesforce should have web hooks.
that would make them more useful, less silo’d off into just processing data in their world
here’s a little microplatform i made last month.
a twitter bot platform using web hooks.
in fact, i built it with web hooks... using mailhook and appjet.
General Systems
Theory
central tenet is value is not in the elements or parts of a system
General Systems
Theory
the real value is in the interactions, how they work together.
this creates the emergent phenomenon of a system, and defines its behavior