【问题标题】:Fulfillment error occurred when trying to test google action in voice assistant尝试在语音助手中测试谷歌操作时发生履行错误
【发布时间】:2019-11-19 08:31:56
【问题描述】:

我正在尝试创建一个 webhook,它将获取 Intent 和当前状态、更改状态并使用用于 node.js 的 actions-on-google 库发回回复。

index.js如下:

'use strict';

const {dialogflow} = require('actions-on-google');
const functions = require('firebase-functions');
const app = dialogflow({debug: true});

app.intent('welcome', conv => {
  let replyState = setReplyState( conv, 'prompt' );
  let intent = getIntentName( conv );
  sendReply( conv, intent, replyState );
});


function getReplyState( conv ){
  return conv.data['replyState'];
}

function setReplyState( conv, state ){
  conv.data['replyState'] = state;
  return state;
}

function getIntentName( conv ){
  return conv.intent;
}

const welcomeReplies = [
  "Welcome!"
];


const allReplies = {
  welcome: welcomeReplies,
};

function sendReply( conv, intent, replyState ){

  let repliesNamed = replyState;
  let replies = allReplies[repliesNamed];
  conv.add( reply );
}

exports.fulfillment = functions.https.onRequest(action);

package.json如下:

{
  "scripts": {
    "serve": "firebase serve --only functions",
    "shell": "firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "engines": {
        "node": "8"
      },
  "dependencies": {
    "firebase-admin": "~6.0.0",
    "firebase-functions": "^2.0.3",
    "actions-on-google": "~2.5.0"
  },
  "private": true
}

发生错误:

格式错误的响应 由于平台响应无效,无法将 Dialogflow 响应解析为 AppResponse:在 agentId:ab93fe46-9eb1-4a6c-aea7-1699d67d7369 和 intentId:1ec758db-d03a-40b7-85fe-189d9245e6e2 的平台响应中找不到 RichResponse 或 SystemIntent。

我推荐了https://github.com/afirstenberg/examples/tree/master/conversation-to-code-2-aog

【问题讨论】:

  • 您可能希望使用函数本身运行中的任何错误日志来更新问题,而不仅仅是您在操作测试控制台中遇到的错误。
  • (个人笔记 - 感谢您阅读我的文章和来源。我希望它会有所帮助。)

标签: dialogflow-es actions-on-google google-home


【解决方案1】:

您没有显示函数执行日志,但看起来action 没有在任何地方定义,因此调用functions.https.onRequest(action); 会返回错误。

在您正在使用的源中,action 定义为

const action = dialogflow();

所有的 Intent Handlers 都注册了

action.intent(...)

虽然你有类似的定义

const app = dialogflow({debug: true});

所以您可能可以将定义函数的行更改为

exports.fulfillment = functions.https.onRequest(app);

解决您眼前的问题。

【讨论】:

    猜你喜欢
    • 2018-11-03
    • 1970-01-01
    • 2019-11-21
    • 1970-01-01
    • 1970-01-01
    • 2018-07-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多