More issues with BasicCard using separate handlers

google-assistant

#1

I’m having trouble with the Google Basic Card again.

My app has got rather large. Following the instructions in the Jovo docs, I decided to separate my Google and Alexa handlers into separate files like 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 AlexaHandler = require("./alexa/alexaHandler.js");
const GoogleHandler = require("./google/googleHandler.js");

const app = new App();

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

and then:

app.setHandler({

  ... LAUNCH(), HelpIntent(), END() etc. ...

};
app.setAlexaHandler(AlexaHandler);
app.setGoogleAssistantHandler(GoogleHandler);

Everything works as usual but now, I get the following error in the logs:

ReferenceError: BasicCard is not defined
at GoogleAction.xxxxxxxIntent (/var/task/google/googleHandler.js:297:31)

It looks like app.js can’t use the BasicCard constructor now I’ve separated my handlers into separate files. Before I separated them, and when they were all in app.js, it was working perfectly. Any ideas on how I can resolve this?

Many thanks
-Simon


#2

You need to add this to every file you want to use the BasicCard class in:

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

#3

Hi Jan,

Thanks so much for the quick response. I thought I had already tried this but I think I had put it in the alexaHandler.js file by accident! Silly me… Everything is working now.


#4

Great! Closing this then


closed #5