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");
}
}
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
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