看不到NodeJS的Google行动中触发的onQuery回调

问题描述 投票:0回答:1

概述

我正在使用Node.js库actions-on-google客户端为actions-on-google设备类型构建智能家居操作。此操作在GCP中部署为云功能。我可以确认以下内容到目前为止效果良好:

  • 与我们的OAuth流程的帐户链接
  • 响应同步意图(即客户端中的Garage Door
  • 响应执行意图(即客户端中的onSync()

问题

尽管其他回调(onExecute()onSync())也能正常工作,但无论如何我们都看不到任何证据表明onExecute()被调用。在Stackdriver中没有显示任何错误,也没有在Stackdriver中的“ Google Actions”过滤器下生成任何日志。

我们期望onQuery()在我们询问Google助理诸如车库门是否已打开?]和马特的门是否已关闭?]时运行。

  • 我们尝试删除onQuery()以查看呼叫是否挂起

  • 我们尝试删除lambda中的async
  • 我们尝试删除所有其他代码并重新部署以隔离headers
  • 代码

    以下代码显示了简单的onQuery()回调。为清楚起见,已删除onQuery()onExecute()代码。

    onSync

    [我们考虑了对'use strict'; const functions = require('firebase-functions'); const {smarthome} = require('actions-on-google'); const app = smarthome({ jwt: require('./XXXXXXXXX-XXXXXXXXXX.json'), debug: true, }); // // Note: Removed onSync() and onExecute() for clarity // app.onQuery(async (body, headers) => { // Expecting to see these logging statements in // Stackdriver like we do for onExecute() and // onSync() ... but nothing ever shows up. console.info('=== onQuery.body', body); console.info('=== onQuery.headers', headers); // We have hardcoded the following ID and a "closed" // state. It matches a valid device ID to the testing // account we are using. return { requestId: body.requestId, payload: { devices: { '2489e4a92799728292b8d5a8b1c9d177': { on: true, online: true, openPercent: 0, } } } }; }); exports.smarthome = functions.https.onRequest(app);的调用中返回的JSON可能缺少特征或某种使其无法正确响应查询意图的可能性,但我们无法识别出任何可能不正确或缺失的东西。这是从onSync()返回的JSON有效负载:

    onSync()

    预期结果

    我们希望Google Assistant响应“”车库门已关闭“

    或其他类似方式。而是,我们收到“对不起,我现在无法到达Matt's Door。请重试。”

    概述,我正在使用Node.js库上的Google行动客户端来为Garage Door设备类型构建智能家居操作。此操作在GCP中部署为云功能。我可以确认...

    javascript node.js actions-on-google google-smart-home
    1个回答
    0
    投票

    在这里回答我自己的问题,以防其他人遇到此麻烦。我的动作处理SYNC和EXECUTE意图而不是QUERY意图的原因归结为我在SYNC响应中为每个设备分配的默认名称/用户名。

    最终,我开始使用以下内容,并且我的动作再次开始按预期响应QUERY的意图:

    © www.soinside.com 2019 - 2024. All rights reserved.