Google cloud functions Dialogflow Fulfillment中的请求:google.actions.v2.AppResponse中的任何字段缺少@type的无效值

Google cloud functions Dialogflow Fulfillment中的请求:google.actions.v2.AppResponse中的任何字段缺少@type的无效值,google-cloud-functions,actions-on-google,dialogflow-es,Google Cloud Functions,Actions On Google,Dialogflow Es,我在尝试调用dialogflow实现的意图时遇到了奇怪的行为(关于Firebase函数,Blaze Plan) 当通过Google Action Simulator调用intent时,它会简单地返回:“我的测试应用程序现在没有响应。请稍后重试。”并且在错误选项卡中: 不可解析的JSONResponse API版本2:无法解析JSON响应字符串,错误为“INVALID_ARGUMENT:”(response_metadata.status.details[0]):google.actions.v2

我在尝试调用dialogflow实现的意图时遇到了奇怪的行为(关于Firebase函数,Blaze Plan)

当通过Google Action Simulator调用intent时,它会简单地返回:“我的测试应用程序现在没有响应。请稍后重试。”并且在错误选项卡中:

不可解析的JSONResponse API版本2:无法解析JSON响应字符串,错误为“INVALID_ARGUMENT:”(response_metadata.status.details[0]):google.actions.v2.AppResponse中任何字段的@type缺少无效值

目的相当简单,如下所示:

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;
        })
}
对my api的调用起作用,它在firebase函数日志中打印响应。但是,我得到的错误如上所述


这里可能有什么问题?

好的,多亏了

我没有正确地兑现诺言。将intent函数更改为以下内容并更改为Dialogflow V2 API后,它现在可以工作了:

function welcome(agent) {
    return api.getUid(accessToken)
        .then((response) => {
            console.log(response);
            agent.add('Welcome.');
            return;
        })
        .catch((e) => {
            console.error(e);
        })
}

更新:虽然此问题已解决,但有时触发意图时仍会出现相同的错误。仅仅在之后再次触发它不会触发错误。这可能是一个bug,可能与v2api处于beta版有关。

好的,多亏了

我没有正确地兑现诺言。将intent函数更改为以下内容并更改为Dialogflow V2 API后,它现在可以工作了:

function welcome(agent) {
    return api.getUid(accessToken)
        .then((response) => {
            console.log(response);
            agent.add('Welcome.');
            return;
        })
        .catch((e) => {
            console.error(e);
        })
}
更新:虽然此问题已解决,但有时触发意图时仍会出现相同的错误。仅仅在之后再次触发它不会触发错误。这可能是一个bug,可能与v2api的测试版有关