What are Webhooks and how to use them in Ruby on Rails?

Jam
2 min readJul 27, 2020

What is a webhook?

Webhooks are user-defined HTTP URL, where other servers/apps can send messages.

When a specific event has occurred on a third-party server, that server can send data to our server with that webhook URL.

Webhook: technical explanation

Suppose, When a developer pushes git commits to our repo, we want to show that in our chat channel. What can we do for that? With a minute interval, we can check the git server for new git commits. and a developer pushes a commit after 1 hour. So, we tried 60 times in an hour and then we got 1 new commit.

We can do it more efficiently with a webhook.
Step 1: Create an HTTP URL that can accept some data and store those data in a database.

Step 2: Tell the git server to make an HTTP request to our server with a new commit history.

Real-life use of webhooks:

You will see the same thing when you integrate some notification service with slack.

--

--

Jam

Software engineer | Full Stack Developer | Programmer | Designer & Entrepreneur