Alexa-skills-kit-sdk-for-nodejs: List 1 Template problem

Created on 14 Nov 2017  路  4Comments  路  Source: alexa/alexa-skills-kit-sdk-for-nodejs

I am trying to build a list for the Echo Show using the List 1 Template. Does the ASK for NodeJS support list 1 template building yet? I get a "The response is invalid" response on the Alexa service simulator every time I try to run this code or something similar to it.

const list1 = new Alexa.templateBuilders.ListTemplate1Builder();

'ListIntent': function() {

let array = ['Apple', 'Orange', 'Banana'];
let template = list1.setTitle('My List').setListItems(array).build(); 

     // Display.RenderTemplate directives can be added to the response
if (this.event.context.System.device.supportedInterfaces.Display) {


    this.response.speak('rendering template').renderTemplate(template);
    this.emit(':responseReady');

}

else {

    this.emit(':tellWithCard', "List support for Echo Show only");

}

}

Most helpful comment

Yes, I am currently looking into this, its a pain as its show in the amazon documentation that the space isn't there and the image is optional. Let me look

All 4 comments

Hi, the Listitem can not be a string, it should be the object that has image, token and text content.
So can you use ListitemBuilder to build the listitem array instead of using the array directly?

const listItemBuilder = new Alexa.templateBuilders.ListItemBuilder();
listItemBuilder.addItem(image, token, text);
listItemBuilder.addItem(image, token, text);
......
listItems = listitemBuilder.build();
let template = list1.setTitle('My List').setListItems(listItems).build(); 

Oh I see how it works now...thanks for the clarification! It also did not work in the simulator until I designated the text type.

const TextUtils = require('alexa-sdk').utils.TextUtils;
const listItemBuilder = new Alexa.templateBuilders.ListItemBuilder();
listItemBuilder.addItem(image, token, TextUtils.makePlainText(text));
listItemBuilder.addItem(image, token, TextUtils.makePlainText(text));
......
listItems = listitemBuilder.build();
let template = list1.setTitle('My List').setListItems(listItems).build();

is there a way to NOT have an image?

const items = new Alexa.templateBuilders.ListItemBuilder();

/*
 * this leaves a big empty space
 */
items.addItem(
  null
  , `token1`
  , makeRichText(`<font size="5">item</font>`)
  , makeRichText(`<font size="2">description</font>`)
  , makeRichText(`<font size="3">price</font>`)
)

/*
 * this leaves a big empty space
 */
items.addItem(
  {}
  , `token2`
  , makeRichText(`<font size="5">item</font>`)
  , makeRichText(`<font size="2">description</font>`)
  , makeRichText(`<font size="3">price</font>`)
)

/*
 * this breaks the intent
 */
items.addItem(
  false
  , `token2`
  , makeRichText(`<font size="5">item</font>`)
  , makeRichText(`<font size="2">description</font>`)
  , makeRichText(`<font size="3">price</font>`)
)

It says that the parameter is optional

Yes, I am currently looking into this, its a pain as its show in the amazon documentation that the space isn't there and the image is optional. Let me look

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lucidokr picture lucidokr  路  5Comments

dkl3in picture dkl3in  路  3Comments

sohanmaheshwar picture sohanmaheshwar  路  3Comments

dillonharlessNHRMC picture dillonharlessNHRMC  路  6Comments

lostvicking picture lostvicking  路  4Comments