Dialogflow Fulfillment 中的请求:对于任何类型的 google.actions.v2.AppResponse 中的任何字段,缺少@type 的无效值
Request in Dialogflow Fulfillment: invalid value Missing @type for any field in google.actions.v2.AppResponse for type Any
我在尝试调用我的 dialogflow fulfillment(在 Firebase Functions,Blaze Plan 上)的意图时遇到了奇怪的行为。
当通过 Google 动作模拟器调用意图时,它只是 returns:"My test app isn't responding right now. Try again soon." 并在错误选项卡中:
UnparseableJsonResponse
API Version 2: Failed to parse JSON response string with 'INVALID_ARGUMENT' error: "(response_metadata.status.details[0]): invalid value Missing @type for any field in google.actions.v2.AppResponse for type Any".
意图很简单,看起来像这样:
const accessToken = request.body.originalRequest.data.user.accessToken;
function welcome(agent) {
api.getUid(accessToken)
.then((response) => {
console.log(response); // This gets printed just fine
return agent.add('Welcome.'); // Doesn't make it to the simulator
})
.catch((e) => {
return e;
})
}
对我的 api 的调用有效,它确实在 firebase 函数日志中打印了响应。但是,我收到如上所述的错误。
这可能是什么问题?
好的,感谢 ,我发现了我的错误。
我没有正确回复承诺。将意图函数更改为以下内容并更改为 Dialogflow V2 API 后,它现在可以工作了:
function welcome(agent) {
return api.getUid(accessToken)
.then((response) => {
console.log(response);
agent.add('Welcome.');
return;
})
.catch((e) => {
console.error(e);
})
}
更新:虽然这个问题已经解决,但在触发意图时,我有时仍然会遇到同样的错误。只是在不会触发错误之后立即再次触发它。这可能是一个错误,可能与 V2 API 处于测试阶段有关。
我在尝试调用我的 dialogflow fulfillment(在 Firebase Functions,Blaze Plan 上)的意图时遇到了奇怪的行为。
当通过 Google 动作模拟器调用意图时,它只是 returns:"My test app isn't responding right now. Try again soon." 并在错误选项卡中:
UnparseableJsonResponse API Version 2: Failed to parse JSON response string with 'INVALID_ARGUMENT' error: "(response_metadata.status.details[0]): invalid value Missing @type for any field in google.actions.v2.AppResponse for type Any".
意图很简单,看起来像这样:
const accessToken = request.body.originalRequest.data.user.accessToken;
function welcome(agent) {
api.getUid(accessToken)
.then((response) => {
console.log(response); // This gets printed just fine
return agent.add('Welcome.'); // Doesn't make it to the simulator
})
.catch((e) => {
return e;
})
}
对我的 api 的调用有效,它确实在 firebase 函数日志中打印了响应。但是,我收到如上所述的错误。
这可能是什么问题?
好的,感谢
我没有正确回复承诺。将意图函数更改为以下内容并更改为 Dialogflow V2 API 后,它现在可以工作了:
function welcome(agent) {
return api.getUid(accessToken)
.then((response) => {
console.log(response);
agent.add('Welcome.');
return;
})
.catch((e) => {
console.error(e);
})
}
更新:虽然这个问题已经解决,但在触发意图时,我有时仍然会遇到同样的错误。只是在不会触发错误之后立即再次触发它。这可能是一个错误,可能与 V2 API 处于测试阶段有关。