What is Webhook? Demo of 'Github Webhook' to 'Azure Function'

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello friends today we are discussing about ebooks yes the book is a way for our application or app to get real-time data which means anything changes on the server and you get notified instantly now this is different from the traditional approach where you need to keep pulling the server to find out about the changes now in this video we will look into what is the book how are they different from the API poling approach and we will set up a web hook to github where we will find out how we can set up the book on the github and then we will see any changes that we make on github sends the data back to the client application so coming up [Music] hello guys welcome to help encoder the channel which talks about technology and helps a coder community out there and in today's video we are discussing about webhook now as we know there are a lot of applications out there and these applications need to talk to each other or communicate with each other so that they can help us or other application for this we have API is like web hook or polling mechanism so that they can communicate with each other to see this in action we will go through a small example let's take a scenario we have to fly from Singapore to Malaysia and I need to book a ticket on this so to do that I will search on the server to check for tickets which are less than $50 so how do I do that I login to the airline's portal and then I search for a ticket between Singapore to Malaysia which is less than $50 I always look for cheap tickets ok now the request reaches the server where it checks for the ticket on the backend now it so once it checks and then it replies to me ok I don't have the ticket which is less than $50 all tickets are costly so I don't take the ticket on the day I come back another day and again check for the ticket which is less than $50 so on the day to again the server replies me back nopes we don't have a ticket which is less than $50 I tried it again on the third day which was a lucky day for me and I requested the server do you still have a ticket which is less than $50 and the service says ok I got it so this methodology where client from a client you request to server and then the server replies you back is called a polling methodology where you keep polling the server for the information that you request if the same methodology we follow using web hooks how do we do that I do need to tell the server again and again because over here I will register my number with the server so I will tell the airline company that here is my number keep it with yourself once you have a ticket which is less than $50 just give me a call Mac so here the client registers the number on the server now once the server has the ticket it will send you the message hi I got you your ticket so this way you don't have to keep polling the server or sending requests to the server asking for a response here the server keeps on looking for you and then when it has that item it will send you the response path so this is a approach which we call as the book ok so now we know the difference between the two and before we start looking into web hooks in action and see how web ebooks really work let's go back and try to understand how it all really started so this all started using API which is application programming interface and we are all surrounded by them all the digital experience on the web that you see is all because of these api's so these api's are the hard working or the heavy lifters they get the real data for you we can also call these api's as SAS software as-a-service so softwares have been exposed on internet or the web by some companies which are used by other people to get their service for example these are the companies like Google YouTube Flickr all of them have api's which are exposed on the web and you can use them to get the data for example Google API is like google weather or Google location is being used by companies like Expedia which helps you find hotels across the world even whatsapp uses Google API is to find the location of your mobile now Google API is are used across the web or even many other applications that you see like example your ATM machines where there are API is of banks which are exposed during using your ATM machines where you stripe in your card and then it sends you the information about your card details so this is what is called polling where you provide some in where you require some information you put in your information and then it you hit the server to extract the data so it is like you asked for the data and then you get response from the server now how does these API is really work API is our interface exposed by companies to help you extract the data so you provide the information in to us particular format which the company requires you to do that and once you do that it gives you response into a JSON or any other different formats so let's see an example for example this open weather map is a company which exposes some api's where you can get the weather information of that particular country so for example they have this API where you need to pass in this URL with a city name it will get you all the information about the weather what is the coordinates what is the weather right now it is drizzling see for example light intensity so this information then you can use it in your application to work on the same now if pulling API can do these many things then why we need web hooks in first place there are some scenarios where we do require web work for example if you want to know an hourly basis if it's gonna rain in a particular location or a particular city then you need to keep pulling this weather map API to know if it's gonna rain on an hourly basis so there will be lot of chattiness on the server you need to keep sending requests to server to get a response back and then in the response you will check whether it's gonna rain or not now the other way out is using Babu case you need to sub you'll subscribe to this service so there will be a web of services through open weather API and where you will tap on and you will subscribe by giving a URL or by some way you will let know that once there's gonna rain then he will inform you back the server we informed a client bag that on that on the subscription channel that you have provided him that that it's gonna rain so you don't have to hit the server again in again to find an information so this these are the places where webhook really comes in so if you want to understand what Web book is a web book is a HTTP push API which is a way for apps to provide other applications with real-time information so there are two things that you need to provide the server before so there is a setup process for web books to work you need to first subscribe by providing a key or the key is something that identifies the client and the server they ties the two and and you know they can authenticate themselves so the client and server gets authenticated using this key so you need to provide a subscription key and the URL to the server so this is a one-time job once this is done then then the server will keep looking out for the information that you requested and once it gets that it will let the client know about the same there are many different companies we have started using webhook for example you have github which is which is doing lot of things with the web hook then we have SendGrid which has couple of services the couple of web hook services that it gives for example it has service where you can tap on to know if there is an unsubscribing mail so once it does have the send grid will send you back or responded on to your client to tell you that there is a none subscription mail or if there is an a bounce mean then it also tells you back to the client that there is a bounce man so there are a lot of different companies like send great video github Foursquare are they are coming up with these web hooks so this is a very interesting approach of how you work with or how the server client communicate on the web now let's take an example of github a book where you can subscribe to you like create delete commit folk or issues and many more and based on your subscription a payload will be sent back to you whenever that event happens and these payloads can be lot verbose and they contain some key data like what are the event types what is the payload for the event type user who performed the event what is the repository or the organization where the event occurred and then the delivery headers may contain some information like which event that triggered so if you see an example of how this payload look like so I have this issues event payload from github so whenever an issue is opened created or deleted or modified so whenever that happens there will be a payload that will be sent back to the client and it can contain lot of information so this is just a tip of an iceberg that I have added over here but there are approximately 200 more lines to go in this payload so this is how the web book responds whenever there is an issue created or the or there is any changes in the issues next we'll be looking into how we can connect to github a book using the azure function and be notified of any issues that happen on the github repository so first I will log in into Azure portal over here I will sign into my account and this is a free account of Azure and to know how do you get a free account I have a video on that on my channel so once you login into your account you can look into the current function apps that you have so if I click over here I don't have right now any account any function apps as of now so let's go and create a new one then I will search for compute and then function app in the lower yup though I click on the function app over I will provide the name of the function app which should be not present over here so let me type in function f Babbage is your web sure webhook okay now rest of the things will remain as it is just yeah rest things as it is let's click on pin to dashboard after this so that it comes on my dashboard so let us click over here and then click on create once we do that it will start deploying this new function app onto your Azure portal still deploying it will take some time so now function app is deployed now we can see the all the function apps that are over here right now you don't have so we click on plus icon so this n click on the create function button and over here you will search for github with fine github JavaScript something it of webbook yeah so this one is with the JavaScript let's do with the JavaScript so github webhook JavaScript which is the one this one and once you click then you can take the name provided so by default one and then you can click on the create so once you click create you will get this boilerplate code over here now if you see there are two things that we require us from here the function URL and the secret key so I will just copy these information into the notepad so let me copy the function URL and then let me copy close it off copy the secret key so this is the secret key between the between the azure and the github which authenticates now once I copy this it's open the github repository so I will go into my github so already signed into my github repository so let's go into my project for repository where I will be doing the very I will be attaching my away book so let us go into the settings first and inside that there is a webhooks option where you can add a web hook over here you need to provide the payload URL so we can just go to your notepad so this is the URL which will be called whenever there is an event over here so the you need to subscribe is subscription this is a subscription URL over here I will choose a JSON response now I will provide the secret key over here so this is a secret key now there are options that you can choose whether you want to everything or you want to choose the type of events over here you will choose some of the events that we want let's let us so these are the different events so let us choose for example issue and all the different issues that are there plus I will add some more like create delete then I will add the webhook so once it gets added so now if you see that the way book has been added so now there is a link between my as your function and then that web book so if you want to see how this will work so I will go to the lock section over here so anything that gets pushed we can see the event getting fired whenever there is a change happening or any issue getting created there will be a event filed to the function as your the function that we have just created under SEO so this is all the book about so there is a hook that has been already created now we are creating an issue over here inside my as you're inside my github so this is for testing purposes now if I go back my geoportal you see that there is some event that has been thrown from the there is a notification sent from the server side to the client side so client never asked for it but it has been thrown automatically so there has been a function started but there has been some error it's okay we'll try it again so there has been error but definitely we can see that there is in ich there has been even that has been thrown from the server side so web book is this is what web book is all about you don't have to keep looking for the events so whenever an issue has been issue created on the github side there will be a event that is filed to that so now let us create give us a comment over here so I will write a comment to that issue so let's see back if that great so now we have a comment so that this is a trigger that I'm Patrol I was talking about so my comment is received over here now let's say let's see again okay cool data so let's see this one if it gets sent back coming back now we have the working web hook get firing events whenever things get changed on the server side so the books have provided lot of advantages on how application communicate with each other now I must tell you I have been in love with the book from the day I learned about them I know after watching this video you must be also in love with them do let us know your story of a book or and how do you use it in your current development or how you plan to use in your future development do you remember to like and subscribe our Channel helpme coder because your likes and subscribes keep us motivated and going so that we can produce awesome content in future do provide your comments if any in the comment section below thanks for watching and happy coding
Info
Channel: helpmecoder
Views: 35,951
Rating: 4.8677163 out of 5
Keywords: Webhook, API, POLLING, GITHUB, AZURE FUNCTION
Id: Nd6FbUWheAg
Channel Id: undefined
Length: 19min 3sec (1143 seconds)
Published: Wed Oct 25 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.