Possible Bug - GoogleAssistant.BasicCard() not showing up

google-assistant

#1

I’m using the following in my project:

let basicCard = new GoogleAssistant.BasicCard()
  .setTitle(videoTitle)
  .setFormattedText(videoSubtitle)
  .addButton('WATCH VIDEO', videoSourceUrl);

this.$googleAction.showBasicCard(basicCard);

Despite having required in the GoogleAssistant Object in app.js:

const { GoogleAssistant } = require("jovo-platform-googleassistant");

I get an error message in the logs, saying that BasicCard is not a contructor:

{ "errorMessage": "GoogleAssistant.BasicCard is not a constructor", "errorType": "TypeError", "stackTrace": [ "GoogleAction.ExampleIntent (/var/task/app.js:113:25)", "Function.applyHandle (/var/task/node_modules/jovo-framework/dist/src/middleware/Handler.js:178:43)", "handle (/var/task/node_modules/jovo-framework/dist/src/middleware/Handler.js:38:23)", "<anonymous>" ] }

Strange, because I’ve checked and the BasicCard.js response file is in the jovo-platform-googleassistant folder.

Any ideas?


GoogleAction not defined
#2

Hey @simon.revill,

Please try this:

const { BasicCard } = require('jovo-platform-googleassistant');

#3

Thanks, @AlexSwe Unfortunately, still no success:

Tried it a few different ways. Did this:

const { App } = require("jovo-framework");
const { Alexa } = require("jovo-platform-alexa");
const { GoogleAssistant } = require("jovo-platform-googleassistant");
const { BasicCard } = require("jovo-platform-googleassistant");
const { JovoDebugger } = require("jovo-plugin-debugger");
const { FileDb } = require("jovo-db-filedb");
const requestPromise = require("request-promise-native");

const app = new App();

app.use(new Alexa(), new GoogleAssistant(), new JovoDebugger(), new FileDb(), new BasicCard());

Then I did what was in the Jovo Docs. I left out some of the optional parameters, but that shouldn’t be a problem:

let basicCard = new GoogleAssistant.BasicCard()
                .setTitle(videoTitle)
                .setFormattedText(videoSubtitle)
                .addButton('WATCH VIDEO', videoSourceUrl);

this.$googleAction.showBasicCard(basicCard);

I’m still getting an error in the logs on CloudWatch:

module initialization error: TypeError
at plugins.forEach (/var/task/node_modules/jovo-core/dist/src/Extensible.js:66:20)
at Array.forEach (<anonymous>)
at App.use (/var/task/node_modules/jovo-core/dist/src/Extensible.js:34:17)
at Object.<anonymous> (/var/task/app.js:18:5)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)

#4

Have you tried this:

const { GoogleAssistant, BasicCard } = require("jovo-platform-googleassistant");

(no need to add BasicCard to the use command)

And then

let basicCard = new BasicCard()
                .setTitle(videoTitle)
                .setFormattedText(videoSubtitle)
                .addButton('WATCH VIDEO', videoSourceUrl);

this.$googleAction.showBasicCard(basicCard);

#5

Thanks for the quick response, @jan . I added BasicCard to the use command just to experiment. Still no luck with testing. I did this:

const { App } = require("jovo-framework");
const { Alexa } = require("jovo-platform-alexa");
const { GoogleAssistant, BasicCard } = require("jovo-platform-googleassistant");
const { JovoDebugger } = require("jovo-plugin-debugger");
const { FileDb } = require("jovo-db-filedb");

const requestPromise = require("request-promise-native");

const app = new App();

app.use(new Alexa(), new GoogleAssistant(), new JovoDebugger(), new FileDb());

And this:

let basicCard = new BasicCard()
  .setTitle(videoTitle)
  .setFormattedText(videoSubtitle)
  .addButton('WATCH VIDEO', videoSourceUrl);

this.$googleAction.showBasicCard(basicCard);

I still get a message on the Google Assistant app saying the app isn’t responding. I checked the logs again. No error message this time, and it looks like it should have worked.

Please ignore the XXXXXXXXX, I’m just filtering out client-sensitive data:

{
    "payload": {
        "google": {
            "richResponse": {
                "items": [
                    {
                        "basicCard": {
                            "title": "XXXXXXXXXXXXXXXXXXX",
                            "formattedText": "XXXXXXXXXXXXXXXXXX",
                            "buttons": [
                                {
                                    "title": "WATCH VIDEO",
                                    "openUrlAction": {
                                        "url": "XXXXXXXXXXXXXXXXXXXXXXX"
                                    }
                                }
                            ]
                        }
                    }
                ]
            },
            "userStorage": "{\"userId\":\"ABwppHHTDeI8gcgBhYb-86rqlHBenLkqMijz5g2ksoG11zufK3cZC229G3ZEjMStKazz0F5DLXkuzJ4GaI0wTwms_MI\"}"
        }
    }
}

#6

One thing I noticed while looking at your response JSON: It doesn’t include a speech response. Could you try adding a this.tell('Test') to see if this might solve the problem?


#7

@jan Great, that works now. I was so focused on the card, I didn’t think about the speech. I suppose I need to remember that this is a voice app!

Thanks for that. Maybe another update for the Jovo docs:

const { GoogleAssistant, BasicCard } = require("jovo-platform-googleassistant");

// and

let basicCard = new BasicCard()

I’m definitely making a note of that.
Thanks again, guys!