In the last section we finished up our local tunnel's setup.
The last thing we have to do is make sure that we instruct send grid that any time it receives some
type of click event from one of our e-mails.
It should send these event notifications over to this specific you RL that is being maintained by our
application specifically this local tunnel address right here.
So let's change over to our Saenger dashboard and set this thing up and then test it out.
So I've already taken the liberty of opening up my said grid dashboard so all I have to do is open up
a new browser tab go to send grid and log in and you should be at the screen right here.
Once I'm here I'll find my left hand now.
And I'm going to scroll down to the settings section.
I'll expand settings and then I will find mail settings right here.
That inside of mail settings there's a lot of stuff going on in here.
The one that we specifically want is event notification.
So this is the Web hook interface right here.
I'm going to first make sure that I turn on event notification.
We were then asked to provide an age TTP post your l.
So this is essentially where we want send grid to send information.
Every single time someone clicks on one of the links inside of our email.
So for us right now in the development environment we're going to make sure that we provide a URL of
our local tunnel address.
So a local tunnel we received this request and then forwarded on to our local machine and then the request
will be eventually forwarded on to localhost 5000 which is our express server.
So to make sure that I get the right you are well I'm going to go back over to the terminal.
I'll scroll up a little bit and we'll find that debug statement that had said specifically your u r
l is blah blah blah.
So I'm going to just copy paste this thing right here just to make sure I'm using the right one.
So going to copy that link.
I'll go back over to the post you are right here.
I'll paste it in.
And the real gotcha right here we do not only specify the domain we are specifying the exact you are
l with the route that we want any of these Web Hoque notifications to be sent to.
And so remember way long ago we had agreed when looking at all of our survey routes we had said that
we would expect any feedback requests to be sent to API slash surveys slash WebEx.
So back over we will say yes send any requests that come into this local Tunnell server scroll out and
see this entire domain.
And I'm sorry I know the font here is very small.
So we will say slash API slash surveys slash Web looks like.
So now we can use this button right here to test the actual integration.
And I'm going to really suggest that we do that right now just so we make sure everything is set up
correctly if we click the button right now however we do not have a route of API slash survey slash
web hooks set up inside of our express server just yet.
So let's take a quick moment to go set up some little debug route for that or some debug route handler
and then we will use this test to your integration button.
So I'll change back over to my code editor.
I'm going to find my routes survey route start G-S file and inside of here I'm going out on a new route
handler of app dot post.
So any time someone makes a post request to a slashy API slash surveys slash web hooks and like I said
I want this to be really just a kind of debug helper right now.
So I'll take the request and the response and we'll just Konst alog the request body.
So we'll see what is a typical typical request.
That said great is going to send over to our server.
So a console log out the body of the request and then just to be nice to send great.
We're not going to leave the request hanging.
We'll send back an empty object.
We don't actually have to send anything back at all.
We're just going to make sure that we're going to kind of close off the request and not leave said grid
hanging.
OK.
So we'll save this file.
We'll make sure that we get our reload at the terminal.
So we now have that additional router setup.
So now go back over said grid and I'll click on the test integration button.
Now when I do if I scroll up to the top I should see a sample event notification will be sent to your
endpoint shortly.
So a nice green message appear if you get something that's red.
Well chances are you probably made a typo in your set up right here.
So just make sure you get that green message up top.
So that's going to instruct send grid to send a test request over to our Web hook that we just defined.
So now we can go over to our terminal and see if that console log produced anything.
And so when we flip back over to the terminal we don't immediately see anything just yet.
But that's not necessarily the worst thing in the world.
Let's double check the route name here and see I've got API surveys web hooks in and back over here.
I have API slash surveys slash books so that's fine.
Just remember every now and then it takes some amount of time for Saenger to actually get the requests
over here.
So let's take a quick break.
Kind of let the Web hook percolate do its thing and then when we come back in the next section we'll
make sure that we're actually getting the request logged out over here.
So I'll see you in just a minute.