Consume webhooks via SSE

No need to create webservers, reverse proxies, domains, certificates just to consume a webhook. Start handling events directly. Also available through the browser.

event-handler.js
package.json
const mySecretId = "ihatewebhooks"
const eventSource = new EventSource(
`https://webhook.stream/sse/${mySecretId}`)
eventSource.onmessage = (m) => {
console.log('New Message: ', m)
}

Introduction

What is this

Skip to getting started

Getting started

Step-by-step guide to setup your first stream


Why

What are Webhooks?

Webhooks are HTTP callbacks triggered by some event. When an event occurs, the source site makes an HTTP request to the URL configured for the webhook.

What are Server Sent Events(SSEs)?

Server-Sent Events (SSE) helps in consuming messages in an event-based way via HTTP. Data is sent one-way over HTTP and when available pushed to the client in realtime. Using SSEs in our case requires only to make an HTTP GET request. More on SSEs

Why is consuming Webhooks easier with Webhook.stream?

Most webhook publishers require that the consumer exposes an https endpoint. Setting up https can be difficult - in addition to setting up a webserver to handle the logic, in most cases you would probably need a reverse proxy to terminate the SSL, messing up with configuration to get a certificate, buying a domain and that's just for the single server use-case.

Planning to handle many messages will require you to set it up all behind a load balancer and manage some form of a queue to manage back-pressure. With Webhook.stream you can consume webhooks via SSEs.

Examples

Without Webhook.stream

  1. You're interested in consuming Telegram webhook to build a chatbot.
  2. Build and test an http endpoint using ngrok.
  3. Deploy the web server behind a reverse proxy.
  4. Setup let's encrypt certificate for the reverse proxy.
  5. Add redis to your cluster to pubsub between instances of your webserver.
  6. Deploy Kafka on your cluster to handle Queues.
  7. Pray.

With Webhook.stream

  1. Subscribe to a topic
curl -N https://webhook.stream/sse/my_secret_key123
  1. Post a message to the topic
curl -d '{"hello":"world"}' -H "Content-Type: application/json" \
    https://webhook.stream/post/my_secret_key123

And that's it!

There's no need to worry about setting up a webserver, ngrok, dns, reverse proxies, ssl certificates, queue servers, pub/sub or anything else.