By the end of this lesson you will know what a webhook is, when you need one, and the four rules every webhook in your app must follow, so you can check the one your agent writes.
You need: lesson 1 done; no code today · Time: 7 minutes
So far your app did the asking. But some news happens at a time you don't control: a customer pays, a student sends your bot a message, someone fills your form. How does your app find out?
- Polling: your app keeps asking "anything new? anything new?", like refreshing your bank app every minute to see if the salary came.
- Webhook: you give the other service an address once, and it calls you the moment something happens, like the bank sending you an SMS when the salary arrives.
A webhook is a request that another service sends to your server when an event happens. Your server is the one answering this time.
Polling keeps asking. A webhook waits to be called. Why?Polling wastes calls (and often money or rate limits), and you still learn late. Webhooks are instant, but they bring new responsibilities, because now strangers on the internet can send requests to your server too.
Log in free to read the rest of this lesson
Every lesson is free. A free account unlocks all of them and saves your progress.
Still to come in this lesson:
- Where you will meet webhooks
- Rule 1: a public HTTPS address
- Rule 2: check it really came from them
- Rules 3 and 4: reply fast, process each event once
- Make the agent prove all four rules
- Recap