ffritz
ffritz

Reputation: 2261

Request in Dialogflow Fulfillment: invalid value Missing @type for any field in google.actions.v2.AppResponse for type Any

I am encountering weird behaviour when trying to call an intent on my dialogflow fulfillment (on Firebase Functions, Blaze Plan).

When the intent is called via the Google Action Simulator, it simply returns: "My test app isn't responding right now. Try again soon." and in the errors tab:

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".

The intent is rather simple and looks like this:

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;
        })
}

The call to my api works, and it does print the response in the firebase function logs. However, I am getting the error as described above.

What could be the issue here?

Upvotes: 0

Views: 533

Answers (1)

ffritz
ffritz

Reputation: 2261

Okay I found my error thanks to https://stackoverflow.com/a/45515472/4755172.

I wasn't returning the promise properly. After changing the intent function to the following, and also changing to Dialogflow V2 API, it works now:

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

UPDATE: While this problem is solved, I am still getting the same error sometimes when triggering the intent. Simply triggering it again right after doesn't trigger the error. This could be a bug, maybe having to do with the V2 API being in beta.

Upvotes: 2

Related Questions