如何在本地开发Google行动? [英] How to develop google actions locally?

查看:79
本文介绍了如何在本地开发Google行动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题对您来说可能听起来很基本或很la脚,但是我对此的经验确实为零。我是Google Actions的新手,我对Javascript不太了解。我的问题是,如何在不使用Google提供的在线编辑器的情况下开发Google Action?你能一步一步地跟我讲吗?我尝试将自己注册到代码实验室练习中,希望对我有帮助,但是在代码实验室练习中,我已经从github克隆了很多代码,而这正是我用来使所有代码正常工作的原因。但是现在我想为我们的真实项目编码,所以我不知道如何从头开始。我知道如何创建代理和其他东西。但是我不知道如何在本地开发。请帮我。

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.

推荐答案

如果您遵循为Google助手(第2级)构建操作代码实验室,您会看到它讨论了在步骤3中设置本地开发。如果您向下滚动至该页面的第4部分,则下面的内容将替换第4部分中的某些内容。

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.

而不是键入 firebase deploy 提示,代替类型

firebase serve --only functions

这是为了代替将代码发送到服务器,而是在模拟环境的本地环境中运行代码Firebase云功能配置。它将显示本地主机上可用的完整路径。如果您的函数被命名为 webhook,它将显示如下内容:

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:


功能:webhook: http:// localhost:5000 / your-project / us-central1 / webhook

现在,您可以在其他窗口中使用ngrok命令,例如

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

ngrok http 5000

,该窗口将显示外部的URL和主机名点。因此可能类似于:

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


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

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

您可以将这两个结合起来您应该用作实现Webhook URL的URL。使用我们的示例,它将类似于

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

要放入Dialogflow实现URL设置中。

that you would put into the Dialogflow fulfillment URL setting.

然后您可以在更改以下内容时停止并启动本地Firebase托管您的代码,并使用ngrok控制台检查请求和响应。如果您停止了ngrok命令行,则再次启动它时,将获得一个新的主机名,并且还需要在Dialogflow中对其进行更改。

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.

这篇关于如何在本地开发Google行动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆