0
votes

We are trying to get DialogFlow / Google Actions to link to an external OAuth account within a conversation. Upon following the examples we are consistently getting request validation errors that we don't know how to resolve. As far as I can tell we are doing everything by the book.

Our questions:

  1. Why won't DialogFlow kick off the authentication process?
  2. The documented webhook response for requesting the sign-in helper not have the same schema as a standard DialogFlow webhook response. Is the sign-in helper response supposed to be used for something else?...

Things we have tried:

  • We have configured our app and OAuth credentials per the documentation
  • We have verified that we can fetch an OAuth token from the service via the OAuth 2.0 playground
  • We have enabled transactions on the Action.

Our intent code is as follows:

const { DialogflowApp } = require('actions-on-google'); 
const { ActionsSdkApp } = require('actions-on-google');

function processV2Request (request, response) {
  ...
  let app = new DialogflowApp({request: request, response: response});
  let sdkapp = new ActionsSdkApp({request: request, response: response});
  const actionHandlers = {
    'pto': () => {
        app.askForSignIn();
    }
    ...
  }
  ...
}

When we execute this intent, we receive the following debug error message about a speech field.

"agentToAssistantJson": {
  "message": "Unexpected apiai response format: Empty speech response",
  "apiResponse": {
    "id": "751e4716-a94d-4d11-908d-3ee193092d9c",
    "timestamp": "2017-12-05T19:52:01.962Z",
    "lang": "en-us",
    "result": {},
    "status": {
      "code": 206,
      "errorType": "partial_content",
      "errorDetails": "Webhook call failed. Error: Failed to parse webhook JSON response: Cannot find field: speech in message google.cloud.dialogflow.v2beta1.WebhookResponse."
    }
  }
}

If instead we try using the ActionsSdkApp, sdkapp.askForSignIn(), we get an error message about a conversation_token field.

"agentToAssistantJson": {
  "message": "Unexpected apiai response format: Empty speech response",
  "apiResponse": {
    "id": "7de79093-6db8-44ee-8717-16b0f317174c",
    "timestamp": "2017-12-05T19:54:29.709Z",
    "lang": "en-us",
    "result": {},
    "status": {
      "code": 206,
      "errorType": "partial_content",
      "errorDetails": "Webhook call failed. Error: Failed to parse webhook JSON response: Cannot find field: conversation_token in message google.cloud.dialogflow.v2beta1.WebhookResponse."
    },
  }
}

And if it's helpful, here's our package.json. It's the DialogFlow default as of recently, with a bumped up version of actions-on-google.

{
  "name": "dialogflowFirebaseFulfillment",
  "description": "This is the default fulfillment for a Dialogflow agents using Cloud Functions for Firebase",
  "version": "0.0.1",
  "private": true,
  "license": "Apache Version 2.0",
  "author": "Google Inc.",
  "engines": {
    "node": "~6.0"
  },
  "scripts": {
    "start": "firebase serve --only functions:dialogflowFirebaseFulfillment",
    "deploy": "firebase deploy --only functions:dialogflowFirebaseFulfillment"
  },
  "dependencies": {
    "actions-on-google": "^1.6.x",
    "firebase-admin": "^4.2.1",
    "firebase-functions": "^0.5.7",
    "apiai": "^4.0.3"
  }
}
1
Are you intentionally using the Dialogflow v2 API? (which is different than the Actions-on-Google v2 API.)Prisoner
We've tried it with both the v1 and v2 APIs and get problems either way. Is v1 the recommended version?John Hoerr
Dialogflow v2 is still in beta and not recommended for production yet. Mostly wanted to narrow things down.Prisoner

1 Answers

1
votes

We determined that in addition to having Transactions enabled for the app, you must also change the Development Sandbox toggled to Active:

enter image description here