HTTP API

Summarized using AI

Webhooks: The Easy Way

Mayra Lucia Navarro • June 25, 2024 • online

In the video titled "Webhooks: The Easy Way," Mayra Lucia Navarro presents an introduction to webhooks, aiming to make the concept accessible for beginners. She begins by discussing the fundamental concepts of communication involved in webhooks and compares them with other technologies.

Key Points:

  • Introduction to the Speaker: Mayra is a developer from Peru who is actively involved in tech communities and has experience in Rails since 2019.
  • Overview of Communication: The presentation explains the basic elements of communication:
    • Sender and receiver (could be applications or servers)
    • The message being communicated
    • The channel through which the communication occurs
  • How Webhooks Work: Mayra illustrates that webhooks facilitate real-time notifications between applications, emphasizing the roles of senders, receivers, events, and messages within this communication model.
  • Example of Communication: She uses a relatable analogy of a mother calling her family for dinner, where the mother is the sender, the family is the receiver, and the message is about the food being ready.
  • Polling vs. Webhooks: Mayra discusses polling, a method where a service continuously checks for updates from another service, which is resource-intensive. She contrasts this with long polling and then introduces webhooks as a more efficient method of receiving real-time updates automatically when events occur.
  • Technological Evolution: She mentions that companies like EAB have shifted from APIs to webhooks to optimize resource usage and enhance communication efficiency.
  • Implementation in Rails: The latter part of the video provides a brief overview of how to implement webhooks in a Rails application. Mayra describes setting up a server to receive and send JSON data, and shares her practical approach to testing webhook integrations.

Conclusion:

Mayra's presentation successfully demystifies webhooks by breaking down their components and demonstrating their advantages over older communication methods. Webhooks provide a more resource-efficient way to manage real-time notifications, which is essential in modern application development.

Webhooks: The Easy Way
Mayra Lucia Navarro • June 25, 2024 • online

What are Webhooks? What problem do they solve? Let's learn a little about them and how to implement them in Rails.

https://www.wnb-rb.dev/meetups/2024/06/25

WNB.rb Meetup

00:00:00.240 okay I got to talk about web hooks uh
00:00:03.639 this is going to be I think something
00:00:05.680 different because I decided not to make
00:00:07.200 it too technical but something kind of
00:00:09.800 introductions for people for beginners
00:00:12.240 or something like that uh so let's
00:00:16.199 start hi I am from Peru like Mya from
00:00:20.320 Peru I consider myself a forever Junior
00:00:24.640 developer I'm a crazy C lady also like
00:00:27.480 many of
00:00:30.119 Al in this in this in this meeting I
00:00:32.920 know a lot of people here that are cisal
00:00:35.399 ladies
00:00:38.079 too um I tell I am Tech leader here in
00:00:41.680 woman Nary and also I wrote a book I
00:00:44.200 love be involv in a lot of conference a
00:00:47.039 lot
00:00:47.840 of meetings
00:00:51.440 here
00:00:53.320 yeah and I discover about rail since
00:00:57.480 2019 and since then I'm here
00:01:00.640 getting involved about the the
00:01:02.719 communities okay uh the agenda about
00:01:05.560 this meeting is let's talk first about
00:01:08.000 basic concepts then other Technologies
00:01:11.240 um compared with web Hooks and then H
00:01:14.000 small implementation in
00:01:16.280 R let's start with this uh because this
00:01:19.560 is an intro an introduction about how we
00:01:23.040 hooks works and also something related
00:01:25.439 to networking I want to talk first about
00:01:28.280 how is commun the Comm communication
00:01:30.600 process involved here so what are the
00:01:33.600 elements that we use to communicate and
00:01:35.439 then let's compare in how in web Hooks
00:01:37.799 and some technologies are just using
00:01:41.159 them to communicate between
00:01:43.920 them uh let's talk about the
00:01:46.680 communication model I decided just to
00:01:49.399 making an small thing and reduce some
00:01:52.520 things in to try to explain it easier so
00:01:57.000 as we know about communication is like
00:01:59.920 we always have a sender and a
00:02:02.680 receiver we have always a message the
00:02:05.880 thing that we want to uh explain or
00:02:10.000 trying to make yes trying to explain and
00:02:12.760 then we have a channel and let's skip
00:02:15.879 the feedback part because this is not
00:02:17.840 going something that I want to talk here
00:02:21.040 okay when we talk about web hooks this
00:02:23.440 is something that we have here
00:02:25.200 applications that they are going to
00:02:26.920 communicate between each others we will
00:02:28.840 have a cender receiver it could be a
00:02:31.040 server or could be
00:02:32.760 applications uh we will have events and
00:02:35.959 message and web Hook is going to help us
00:02:39.560 to receive notifications in real time uh
00:02:43.360 when it happens in the in one of the
00:02:45.920 applications this is just a little bit
00:02:48.120 about web hooks because I'm going to try
00:02:49.680 topl better
00:02:51.120 later okay let's continue with what is
00:02:54.280 related to the elements of we Hooks and
00:02:56.720 how communication is going to be like a
00:02:59.360 a s it's similar elements that we have
00:03:01.760 here we will have a sender and a
00:03:04.000 receiver like just like Communications
00:03:06.000 it could be applications or servers we
00:03:09.040 will have here an event that is going to
00:03:11.680 trigger
00:03:12.879 something and it's going to send a
00:03:15.599 message here and there is going to be a
00:03:18.319 receiver that is going to receive this
00:03:19.959 message and is going to do something
00:03:22.080 with this
00:03:23.799 message uh if we can make for example in
00:03:28.040 this communication model or something
00:03:29.480 like that is like like our mom is
00:03:31.319 calling us because the food is ready
00:03:34.519 here we will have our mother that is
00:03:36.879 going to be the center as that is well
00:03:40.040 me and my family is going to be the
00:03:42.200 receivers and the channel is going to be
00:03:45.080 the voice of my mom and the mention is
00:03:47.319 going to be the fot is really so it is
00:03:50.360 something like this but in just in a
00:03:53.760 more structur information that is going
00:03:56.040 we are going to receive and send just in
00:03:58.599 based what all the EV that are going to
00:04:00.599 be related to Applications it could be
00:04:03.120 for example if we think about an event
00:04:05.640 this could be
00:04:06.879 when some employee is just going to be
00:04:10.239 in a home boarding and that is going to
00:04:12.560 be the event that is going to trigger
00:04:14.360 something that is going to happen maybe
00:04:17.400 it needs to be registering
00:04:19.639 some uh insurance or some program or
00:04:23.240 maybe something special in the
00:04:26.520 company
00:04:28.039 so I want to talk talk about how it
00:04:31.600 works here we are going we talk about
00:04:34.600 how the event is trigger and how we have
00:04:36.919 a message and the sender receivers that
00:04:39.320 are involed inside all this and and also
00:04:42.120 forgot to mention about the channel That
00:04:43.759 is the web that is when all the things
00:04:46.639 are going to be are going to be
00:04:51.479 done here is one of the example the
00:04:54.400 event the
00:04:56.280 message and the receiver
00:05:00.520 uh the difference between something more
00:05:02.560 simple like Communications and what is
00:05:05.120 web Hook is that in an application is
00:05:08.400 going to send the message automatically
00:05:11.000 when the event occurs and the message
00:05:13.840 that we are going to receive is going to
00:05:15.400 be a structur data that is going to be
00:05:18.240 understand by the sender and the
00:05:21.759 receiver so uh now we're going to talk
00:05:24.880 about why web Hops and what happened
00:05:27.759 before
00:05:29.800 why do we use web hooks now I going to
00:05:33.240 talk about polling because it was on one
00:05:35.520 of the first Technologies or methods
00:05:38.240 that were used for what is communicate
00:05:41.520 between
00:05:43.240 applications uh the difference here is
00:05:45.680 that every time that something happens
00:05:49.319 uh all the time the service is asking
00:05:52.360 all the time about in two five let's say
00:05:55.720 in five seconds is asking something
00:05:58.199 happening something happen two seconds
00:06:01.039 again something happen and only if
00:06:03.560 something happens really happens I just
00:06:06.639 want is going to say yes is happening
00:06:09.120 something and you are going to receive
00:06:11.599 this uh I used to work for IBM before uh
00:06:15.599 we have this kind of technology in go
00:06:18.280 what is related to
00:06:20.039 monitoring monitoring servers monitoring
00:06:23.160 applications and this is one of the most
00:06:25.319 common use for what is related to poing
00:06:28.759 because we we have to check all the time
00:06:32.039 if uh the memory of OB server is not
00:06:34.520 full so all the time we needed to
00:06:37.319 ask to the for example the the server of
00:06:41.720 the client if all the m is full and need
00:06:45.360 we have a list of all the alerts related
00:06:48.360 to that and based on that we knew if
00:06:50.520 something wrong was happening or
00:06:53.280 not okay one of the disadvantages of
00:06:56.759 this technology is that uh you consume a
00:07:00.120 lot of resources because all the time
00:07:02.240 you need to be asking about what is
00:07:04.720 happening here expecting for a
00:07:08.199 response after that we can uh something
00:07:12.840 related to the same poing but improve
00:07:16.199 that is called the long polling but in
00:07:18.479 this time is just it's asking if
00:07:22.000 something happens it the the and it is
00:07:26.680 and even if the other because before
00:07:28.840 here when the server is asking something
00:07:32.440 sorry when the client is requesting the
00:07:35.960 respon is made in those five second
00:07:39.440 let's say 5 Second is doing this and
00:07:42.319 this this and this if something happens
00:07:45.599 no something nothing happens five
00:07:47.120 seconds more something happens nothing
00:07:49.479 happens but the difference with Lum
00:07:51.840 polling is in Lum polling is your
00:07:54.800 request you keep waiting and waiting and
00:07:58.599 waiting and waiting until certain time
00:08:02.120 and then you respond only if something
00:08:04.479 happens of the time it's just you
00:08:07.560 decided it's just 10 seconds and then is
00:08:09.680 when the response is get
00:08:11.840 back and it says if nothing happens
00:08:15.080 you're going to request again and
00:08:17.080 waiting and waiting and waiting so it's
00:08:19.319 all the time expecting that's is what is
00:08:21.440 related for long poing so here is just
00:08:25.479 like it could be real well before here
00:08:29.199 you with if something different
00:08:31.960 different about here is that the problem
00:08:34.440 is to if something happens you're going
00:08:37.039 to know it later but here you skip that
00:08:40.080 part and you make it almost real time
00:08:43.159 the problem is here is you still can
00:08:45.279 consuming the same resources for doing
00:08:47.160 the same well eventually you receive the
00:08:49.839 communication as you want it but it's
00:08:52.160 not the more efficient way to do
00:08:54.480 it so here is where comes web socket uh
00:08:59.480 web sockets is more common and is still
00:09:03.000 use here that is in real time when we
00:09:05.399 have two-way
00:09:07.399 Communications uh we use in the chats
00:09:09.839 online games or what is related to a
00:09:12.920 double communication everything at the
00:09:14.920 same
00:09:16.800 time um well it's one of the most common
00:09:20.720 technologies that I heard lately even
00:09:23.519 before the web
00:09:25.040 Hooks and here is where web hooks comes
00:09:29.000 uh the best part of that sorry I
00:09:32.160 realized that I didn't check this part
00:09:36.279 okay the best part of work Hook is that
00:09:39.959 um when an event is triggered is when
00:09:42.680 some alert is sent is when a message is
00:09:46.320 sent and the and the server the receiver
00:09:49.560 is is going to get the data that is
00:09:52.399 where that is expecting the best part of
00:09:55.279 this is that the resources are going to
00:09:57.360 be um
00:09:59.959 only are use well the consumer sources
00:10:03.560 are reduced and also you get the data in
00:10:05.959 real time not before there are companies
00:10:08.920 like EAB that actually in
00:10:11.240 201 2019 decided to switch from apis or
00:10:15.880 other Technologies just to use web hooks
00:10:18.519 because it was a better consum of
00:10:21.040 resources and also it's based on what is
00:10:26.240 HTTP um okay let's talk about
00:10:29.440 implementation in R all what we need
00:10:32.600 here because it's easier to implement
00:10:35.519 what that's is one of the things here is
00:10:38.240 all what we need is a server in this
00:10:40.240 case ra we're going to be get an event
00:10:44.160 and we need to send a message and this
00:10:46.519 is the part
00:10:47.839 when I need to share with you while was
00:10:53.440 doing here okay here is the the the
00:10:57.600 server in raos
00:10:59.880 all what we have here is just a web
00:11:02.760 controller when we are going to
00:11:11.600 get the workbook is going to be
00:11:14.040 configured in this in this way something
00:11:16.800 simple we're going to get the URL we are
00:11:19.320 going to send and also that is going to
00:11:22.000 send at Json and the data that we are
00:11:24.880 going to send
00:11:26.880 here also the response code and the
00:11:30.000 response body okay here is something
00:11:32.760 that I something to share right now with
00:11:35.560 you because there is a way that in our
00:11:38.519 company we use to test web hooks what we
00:11:41.560 do use is to create something like
00:11:48.079 this for example we create our
00:11:54.279 URL and we are going to get the copy of
00:11:58.120 this URL that is going to receive that
00:12:01.160 we are sending here
00:12:06.399 behind we change this
00:12:13.279 here we start our server
00:12:31.199 and we just go to
00:12:35.480 the and we can see here that something
00:12:37.959 is being
00:12:39.839 sent something is being received and it
00:12:43.199 work and when we get back to this side
00:12:45.720 that
00:12:46.600 is that is is doing the thing we can see
00:12:53.079 that it's what it you
00:12:56.720 it and here is our example we send this
00:13:00.120 data and This Server received the
00:13:04.639 data here we have the example
00:13:09.120 event and we have the message received
00:13:11.920 by the the web
00:13:14.760 hook um here is how how the easiest way
00:13:19.000 to implement some thing like web hooks
00:13:21.560 in
00:13:23.279 rails
00:13:24.959 um that's it thank you
Explore all talks recorded at WNB.rb Meetup
+20