I can deploy to Firebase using "firebase deploy --only functions". However, I'd like to run ngrok in my local computer, as suggested here . How can I do that?
I understand that ngrok will expose a certain URL with a port on the Internet and that it starts locally with a port as parameter. Do I also need to run NodeJS on the same port locally? The sample NodeJS script for using the Inline Editor doesn't declare a NodeJS port. Instead, it has this:
exports.dialogflowFirebaseFulfillment = functions.https.onRequest( ...
Three step process:
Run firebase serve --only functions
. The serve
command simulates the deployment environment on your own machine. You need to be running node.js (6.11.5 preferred, since that is what runs on Firebase Cloud Functions), but you don't need to make any changes to your code.
It will report something like
functions: webhook: http://localhost:5000/project-name/us-central1/function-name
Note the port number (after the "localhost" part) and use that as a parameter for ngrok with a command like ngrok http 5000
. (Don't worry about the "http" part - it will make an https port available.)
The ngrok console will start and will include a line like
Forwarding https://zz99z999.ngrok.io -> localhost:5000
You'll need to combine the URL base from here and the path that firebase has told you for your webhook fulfillment url. In our example, this would be https://zz99z999.ngrok.io/project-name/us-central1/function-name
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With