我可以使用 Python 为 Google Home 构建操作吗

问题描述:

我正在开始开发 Google Home 操作,并希望使用 Python 语言而不是 node js 进行开发,这在 https://developers.google.com/actions/get-started/.

I am starting development of Google Home actions and would like to do so with the Python language instead of node js, provided in the getting started tutorial at https://developers.google.com/actions/get-started/.

我正在阅读教程,但被困在需要使用 node js 来演示事实应用程序的地方.

I was going through the tutorial and was stuck at the point where it requires the use of node js for the demo facts app.

如上所述,我需要为此使用 Python.(我认为网络钩子在这里很重要.不确定它们是什么.)

I need to use Python for this, as mentioned above. (I think web hooks are something of importance here. Not sure what they are.)

webhook 是由操作调用的回调.它将从 Google Assistant 接收包含所有上下文数据的 JSON 负载.Google 会向您在 API.AI 控制台中指定为 webhook 的任何服务发送 POST 请求.然后由您将响应发送回 Google,以便它可以在客户端设备上呈现"该响应.您可以使用 Flask 或任何其他 Python 框架来处理 POST 请求并生成响应.

The webhook is the callback that is called by the action. It will receive a JSON payload with all of the context data from Google Assistant. Google will send a POST request to whatever service you specify in the API.AI console as the webhook. It is then up to you to send a response back to Google so that it can 'render' that response on the client device. You can use flask or any other Python framework to process the POST request and generate your response.

请记住,Google 智能助理可以在各种平台上运行,因此,您需要查看表面"参数以专门针对您正在响应的设备的响应负载.

Remember that Google Assistant can run on a variety of platforms and as such, you will want to look at the 'surface' parameter to specialize your response payload for the device you are responding to.