actions-on-google / assistant-conversation-nodejs

A developer friendly way to fulfill Actions SDK handlers for the Google Assistant
https://actions-on-google.github.io/assistant-conversation-nodejs
Apache License 2.0
104 stars 38 forks source link

Only one Suggestion can be added (except debugging is enabled?!) #42

Closed FelixButzbach closed 3 years ago

FelixButzbach commented 3 years ago

The following code is only working when the app is started in debugging mode:

const {conversation, Card, Image, Suggestion} = require('@assistant/conversation');

const app = conversation({
  debug: true,
});

app.handle('get_meta_data', async (conv) => {

  const currentMeta = await getMeta(); // false in case of an error

  conv.session.params.currentMeta = currentMeta;

 if (!currentMeta) {
    conv.add("Couldn't fetch the meta data at the moment");
 } else {
    conv.add(`Currently playing: ${currentMeta.artist} - ${currentMeta.song}`);
    conv.add(new Card({
      title: "Currently playing:",
      subtitle: `${currentMeta.artist} - ${currentMeta.song}`,
      image: new Image({
        url: currentMeta.album,
        alt: `Album cover for ${currentMeta.artist} - ${currentMeta.song}`,
      }),
      button: {
        name: "Know more about this music",
        open: {
          url: currentMeta.musicUrl,
        },
      },
    }));
  }

  conv.add(new Suggestion({ title: 'Continue radio' }));
  conv.add(new Suggestion({ title: 'Quit' }));
});

If debug is set to false, the JSON response is malformed and the action returns an error to the user. If I remove one of the Suggestions, the code works also when debug=false.

Fleker commented 3 years ago

What does the malformed JSON look like?

FelixButzbach commented 3 years ago

@Fleker the problem went away. Not sure when or why but the code is now working, even with debug=false. Maybe it was some problem with account confusion as I use different accounts to test and deploy, or cache, maybe? Anyways, closing the issue now