How to develop google actions locally?

≡放荡痞女 提交于 2019-12-08 18:09:26

If you have followed the Build Actions for the Google Assistant (Level 2) codelab, you'll see that it talks about setting up for local development in step 3 using Firebase Cloud Functions. If you scroll down to part 4 on that page, what follows replaces some things in part 4.

Instead of typing firebase deploy as it suggests, instead type

firebase serve --only functions

What this does is, instead of sending the code to the server, you run the code locally in an environment that emulates the Firebase Cloud Function configuration. It will show the full path that is available on localhost. If your function is named something like "webhook", it will show something like:

functions: webhook: http://localhost:5000/your-project/us-central1/webhook

This now lets you use the ngrok command in another window with something like

ngrok http 5000

and that window will show the URL and hostname that are the external point. So it might be something like:

forwarding https://8ba32042.ngrok.io -> localhost:5000

You would combine these two to make the URL that you should use as the fulfillment webhook URL. Using our example, it would be something like

https://8ba32042.ngrok.io/your-project/us-central1/webhook

that you would put into the Dialogflow fulfillment URL setting.

You can then stop and start the local firebase hosting as you change things in your code and examine the request and response using the ngrok console. If you ever stop the ngrok command line, when you start it again you'll get a new hostname, and you'll need to change this in Dialogflow as well.

  • Download NGROK
  • Download NODEJS
  • Develop a local webhook using Express on NodeJS
  • Expose this local webhook to the internet using NGROK
  • Use the NGROK generated URL as the fulfilment to your Dialogflow agent.
  • Integrate Google Assistant with Dialogflow and test it.

Here is a tutorial to start with

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!