问题
My question might sound basic or lame to you but I really have zero experience with this. I am so new to Google Actions and I don't have that much idea with Javascript. My question is how do I develop a Google Action without using the online editor google provided? Can you please narrate it to me step by step? I tried enrolling myself in codelab exercises that I hope might help me but in the codelab exercise, there was already a bunch of codes I cloned from github and that was what I used to make it all work. But now that I want to code for our real project, I don't know how to start from scratch. I know how to create an agent and stuff.. but I don't know how to develop locally. PLEASE HELP ME. THIS IS FOR OUR THESIS.
回答1:
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.
回答2:
- 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
来源:https://stackoverflow.com/questions/51816304/how-to-develop-google-actions-locally