У меня проблема, я создаю приложение для помощника Google, и мне нужно поместить элементы в список, проблема в том, что я не знаю, сколько элементов содержит список.В официальной документации есть пример того, как статически вставить элементы в то, как я могу их пожертвовать?это ссылка на документацию https://developers.google.com/actions/assistant/responses#sample_code_7 это пример документации
if (!conv.surface.capabilities.has('actions.capability.SCREEN_OUTPUT')) {
conv.ask('Sorry, try this on a screen device or select the ' +
'phone surface in the simulator.');
return;
}
// Create a list
conv.ask(new List({
title: 'List Title',
items: {
// Add the first item to the list
'SELECTION_KEY_ONE': {
synonyms: [
'synonym 1',
'synonym 2',
'synonym 3',
],
title: 'Title of First List Item',
description: 'This is a description of a list item.',
image: new Image({
url: 'IMG_URL_AOG.com',
alt: 'Image alternate text',
}),
},
// Add the second item to the list
'SELECTION_KEY_GOOGLE_HOME': {
synonyms: [
'Google Home Assistant',
'Assistant on the Google Home',
],
title: 'Google Home',
description: 'Google Home is a voice-activated speaker powered by ' +
'the Google Assistant.',
image: new Image({
url: 'IMG_URL_GOOGLE_HOME.com',
alt: 'Google Home',
}),
},
// Add the third item to the list
'SELECTION_KEY_GOOGLE_PIXEL': {
synonyms: [
'Google Pixel XL',
'Pixel',
'Pixel XL',
],
title: 'Google Pixel',
description: 'Pixel. Phone by Google.',
image: new Image({
url: 'IMG_URL_GOOGLE_PIXEL.com',
alt: 'Google Pixel',
}),
},
},
}));
в Java будет выглядеть так, но в nodejs как я могу сделать
//list with my data
List<Element> elements= new ArrayList<>();
List<ListSelectListItem> items = new ArrayList<>();
ListSelectListItem item;
for (Element _e : elements) {
item = new ListSelectListItem();
item.setTitle(_e.getTitele())
.setDescription(_e.getDesctiprions())
.setOptionInfo(
new OptionInfo().setKey(_e.getKey())
.setImage(
new Image().setUrl(_e.getUrlImage());
items.add(item);
}
IЯ Java-разработчик, и недавно я изучаю NodeJS, поэтому мне еще нужно кое-что понять, заранее спасибо за помощь