actions-on-google / actions-on-google-testing-nodejs

Apache License 2.0
75 stars 18 forks source link

Empty responses using dialogflow #28

Closed Wimsen closed 5 years ago

Wimsen commented 5 years ago

I can't get the dialogflow example to work. I have an app in dialogflow, but action.startWith() always returns empty responses. I have an intent in dialogflow named TestIntent with Test me defined as a training phrase. My code is:

"use strict";
const { ActionsOnGoogleAva } = require("actions-on-google-testing");
const { expect } = require("chai");
const action = new ActionsOnGoogleAva(require("./test-credentials.json"));

action.locale = "en-US";
action.setLocale("en-US");
action.startTest("Bank Test", action => {
    return action
        .startWith("Bank Test")
        .then(response => {
            return action.send("Test me");
        })
        .then(response => {
            console.log(response);
        });
});

action.startTest("Bank Test", action => {
    return action
        .start()
        .then(response => {
            return action.send("Test me");
        })
        .then(response => {
            console.log(response);
        });
});

Both the responses - from first running action.start or action.startWith(), and then action.send() returns the following empty response:

{ 
  micOpen: false,
  textToSpeech: [],
  displayText: [],
  ssml: [],
  suggestions: [] 
}

My Actions on Google project has Bank Test as its invocation. The project has a default welcome intent defined in dialogflow as well, with a defined text response.

I originally thought this to be an issue with locale, so I explicitly specified en-US in the test code, Actions on Google console, and DialogFlow Console, but still no luck.

test-credentials.json is generated using generate-credentials.js towards the correct project. If I go to the dashboard for the Google Assistant API under my Google Cloud project, the graphs show that the API is being used, so the error is probably not regarding authentication.

Fleker commented 5 years ago

In the Actions console, you will need to make sure that your Action is in test mode. If it works in the simulator, it will work in the automated testing environment.

Wimsen commented 5 years ago

That's just the thing - it works fine in the simulator...

Fleker commented 5 years ago

Are you using the same account in both cases? That's pretty unexpected.

Wimsen commented 5 years ago

Yes, using the same account. Just tried setting up a new project, and the same is happening there as well - just empty responses returned. However, the API dashboard for Google Assistant shows traffic in the console.

I have tried using both .start()and .startWith(), with no parameters, passing the project name, and passing the intent name, with no luck.

It may be a configuration issue, but I've tried several times following the readme. I have

Fleker commented 5 years ago

Can you see if your Action is seeing these requests?

nebdil commented 5 years ago

@Wimsen were you able to resolve this on your side? I have the same issue after following the steps from the README

Wimsen commented 5 years ago

No, have not got it working yet.

The metrics for the Google Assistant API within Google Cloud console show incoming requests. I am unable to see if the Actions on Google analytics say the same - the app is not yet published and analytics are not available. We are using Dialogflow, and the Dialogflow analytics show no incoming requests.

atulep commented 5 years ago

Can you try printing out response after calling start() method?

How do you implement the fulfillment for your "TestIntent"?

Wimsen commented 5 years ago

Just updated to the latest version, and the responses are now longer empty, and it seems to work fine. However, I'm now facing a locale issue.

My action is written in Norwegian, and the corresponding locale is no-NO. If I'm running the tests without specifying locale, I get the expected response from the intents defined for english. If I try to set locale either using action.locale = "no-NO" or action.setLocale("no-NO"), I get the following error:

  Error {
    code: 3,
    details: 'Invalid \'dialog_state_in\': unsupported language_code.',
    metadata: Metadata {
      _internal_repr: {},
    },
    message: '3 INVALID_ARGUMENT: Invalid \'dialog_state_in\': unsupported language_code.',
  }

, thrown from the grpc library. However, the utterances toward Google Assistant have changed language from to Norwegian, so it seems this is an issue with grpc and not this library.

rtuin commented 5 years ago

I'm getting the same error as described here for the locale nl-NL.

What is the best way around this?

Fleker commented 5 years ago

This implementation may not support the entire set of languages and locales. Behind the scenes, this library uses the Assistant SDK, which only supports the languages in this doc.

rtuin commented 5 years ago

@Fleker That explains, thanks for clarifying!

I don't think localization is necessary per se, it would help if this project allows for complete custom invocation phrases. Currently even startWith in en-US prepends "Talk to" to the invocation name. The project I'm working on has the Dutch locale, and it would help already if it's possible to start it with "Praat met <projectname>" instead of how it is now: "Talk to Praat met <projectname>".

Would you be open for an addition to the framework that allows this?

Fleker commented 5 years ago

We do support directly the send method if you want to try sending strings directly. I understand it may not be ideal in every case, but without general support in the Assistant SDK for these locales, a workaround for these specific cases would be necessary.

chandan4u commented 5 years ago

Just updated to the latest version, and the responses are now longer empty, and it seems to work fine. However, I'm now facing a locale issue.

My action is written in Norwegian, and the corresponding locale is no-NO. If I'm running the tests without specifying locale, I get the expected response from the intents defined for english. If I try to set locale either using action.locale = "no-NO" or action.setLocale("no-NO"), I get the following error:

  Error {
    code: 3,
    details: 'Invalid \'dialog_state_in\': unsupported language_code.',
    metadata: Metadata {
      _internal_repr: {},
    },
    message: '3 INVALID_ARGUMENT: Invalid \'dialog_state_in\': unsupported language_code.',
  }

, thrown from the grpc library. However, the utterances toward Google Assistant have changed language from to Norwegian, so it seems this is an issue with grpc and not this library.

I'm facing empty response issue, before it working, suddenly i find it stop working. what version your are using to fix this issue

Fleker commented 5 years ago

I can't reproduce this issue. We can open this up if there's more information.