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

Apache License 2.0
75 stars 18 forks source link

Only textToSpeech in response from Dialogflow #48

Open BBland1999 opened 4 years ago

BBland1999 commented 4 years ago

I having an issue where only textToSpeech responses seem to work properly. I'm trying to test that the correct suggestions appear but only the textToSpeech array does. When I test it with the google actions console, I can see that the suggestion chips are appearing. I have tried it with a card as well and had the same results.

test.js:

'use strict';
const chai = require('chai');
const winston = require('winston');
var expect = chai.expect;

winston.loggers.add('DEFAULT_LOGGER', {
    console:{
        level: 'error',
        colorize: true,
        label: 'Default logger',
        json: true,
        timestamp: true
    }
});

const { ActionsOnGoogleAva } = require('actions-on-google-testing');
const action = new ActionsOnGoogleAva(require('./test-credentials.json'));

action.startTest('NAME OF THE TEST', action => {
    return action.start('my test app')
        .then(res => {
            return action.send('lmao');
        })
        .then(res => {
            console.log("\n----------\n");
            console.log(res);
            console.log("\n----------\n");
        });        
});

test.js output:

(node:10552) DeprecationWarning: grpc.load: Use the @grpc/proto-loader module with grpc.loadPackageDefinition instead
(Use `node --trace-deprecation ...` to show where the warning was created)
| ** Starting test NAME OF THE TEST **
/ > Talk to my test app my test app
/ {
  micOpen: false,
  textToSpeech: [
    'Getting the test version of my test app.\n' +
      'Good day! What can I do for you today?'
  ],
  displayText: [],
  ssml: [],
  suggestions: []
}
- > lmao
| {
  micOpen: false,
  textToSpeech: [ 'These are suggestion chips' ],
  displayText: [],
  ssml: [],
  suggestions: []
}
/
----------

{
  micOpen: false,
  textToSpeech: [ 'These are suggestion chips' ],
  displayText: [],
  ssml: [],
  suggestions: []
}

----------

test passes
> cancel
\ {
  micOpen: false,
  textToSpeech: [],
  displayText: [],
  ssml: [],
  suggestions: []
}
test ends
/ NAME OF THE TEST

  1 test passed

raw response from actions console test:

{
  "conversationToken": "[]",
  "expectUserResponse": true,
  "expectedInputs": [
    {
      "inputPrompt": {
        "richInitialPrompt": {
          "items": [
            {
              "simpleResponse": {
                "textToSpeech": "These are suggestion chips"
              }
            }
          ],
          "suggestions": [
            {
              "title": "suggest 1"
            },
            {
              "title": "suggest 2"
            },
            {
              "title": "suggest 3"
            }
          ]
        }
      },
      "possibleIntents": [
        {
          "intent": "assistant.intent.action.TEXT"
        }
      ]
    }
  ],
  "responseMetadata": {
    "status": {
      "message": "Success (200)"
    },
    "queryMatchInfo": {
      "queryMatched": true,
      "intent": "5e3602df-efba-4ac8-b6c2-1962e678c745"
    }
  }
}
Fleker commented 4 years ago

Can you disable and re-enable testing in the console?

BBland1999 commented 4 years ago

Can you disable and re-enable testing in the console?

I just did (in the actions console) and am seeing the same results.

codeforequity-at commented 4 years ago

I have the same problem. When going deeper into this and doing some debugging I found out that the debug_info field in the response received from the AssistRequest is always null - although this actually should contain the suggestion chips, cards etc.

In the Logs Viewer I can see the request, and Dialogflow returns everything I expected - it just isn't part of the AssistResponse.

@Fleker any idea whats wrong here ?

Received response from agent with body: HTTP/1.1 200 OK Server: nginx/1.13.6 Date: Thu, 20 Aug 2020 12:14:52 GMT Content-Type: application/json; charset=utf-8 X-Content-Type-Options: nosniff google-actions-api-version: 2 Cache-Control: no-cache, no-store, max-age=0, must-revalidate Pragma: no-cache Expires: Mon, 01 Jan 1990 00:00:00 GMT P3P: CP="This is not a P3P policy! See g.co/p3phelp for more info." Content-Security-Policy: script-src 'report-sample' 'nonce-xfl/xTl7c2AWJqq0DeyH4w' 'unsafe-inline';object-src 'none';base-uri 'self';report-uri /_/DialogflowRuntimeAogHttp/cspreport;worker-src 'self' Content-Encoding: gzip X-XSS-Protection: 0 X-Frame-Options: SAMEORIGIN Set-Cookie: NID=204=aaaa expires=Fri, 19-Feb-2021 12:14:52 GMT; path=/; domain=.google.com; HttpOnly Via: 1.1 google Alt-Svc: clear Transfer-Encoding: chunked { "conversationToken": "[]", "expectUserResponse": true, "expectedInputs": [{ "inputPrompt": { "richInitialPrompt": { "items": [{ "simpleResponse": { "textToSpeech": "Default response of send buttons" } }, { "simpleResponse": { "textToSpeech": "suggestions:" } }], "suggestions": [{ "title": "Item1" }, { "title": "Item2" }, { "title": "Item3" }] } }, "possibleIntents": [{ "intent": "assistant.intent.action.TEXT" }] }], "responseMetadata": { "status": { "message": "Success (200)" }, "queryMatchInfo": { "queryMatched": true, "intent": "89404df9-1732-4016-8530-e1789008bbe6" } } }
pglejzer commented 3 years ago

Any fix on this problem? @Fleker @yoichiro

Fleker commented 3 years ago

Is your action built using Dialogflow or Actions Builder? If the latter, you should use the Assistant Conversation testing lib.

pglejzer commented 3 years ago

I have many projects on Dialogflow and actions builder and I'm trying to use these libraries depends what I need.