So you tried out the tutorial in its entirety. But you are not getting the expected response.
Here is a troubleshooting sequence.
Use the Show JSON button to see the webhook status
When you don't see the response you are expecting, click on the Show JSON button and note down what you see in the webhook status.
Note: In your webhook status, you might see a couple of things.
You might see a message which indicates there was a timeout, or perhaps an Error 500 which is an internal server error.
Checking the Firebase logs
You have noted down the webhook status and the corresponding error. Which type of error is it?
Internal Server Error
If you see a 500 error - an internal server error, then check out your Firebase logs. Here is how to find it:
Go to Firebase console while logged in to your Google account. Click on Functions from the left pane, and click on Logs on the upper tab.
You can see all the logs as you interact with your Cloud Function. Usually, an Internal Server Error will show you an explicit error, e.g. variable is not defined, or perhaps some dependency error. Try to see if you can make sense of the error and then fix it.
A more silent and harder to debug failure is a simple timeout. We will resort to the famous printf debugging process in this case. 🙂
Sprinkle your code with plenty of console.log statements, in fact probably one per statement of execution. See how far down your code the console logs show up. When you see an expected console.log message not showing up in your logs, you can usually use it to infer which line of code was throwing the error and proceed with troubleshooting.
What about local debugging?
Now, probably a much simpler option when it comes to debugging your webhook would be to simply figure out how to use ngrok and configure your IDE to accept requests coming in to ngrok. That would have to wait for a future post as I need to figure it out for myself first. 🙂