Actions on google 调用app.buildCarousel()时如何在for循环中迭代调用addItems
我想基于结果集在旋转木马中创建多个项目。我使用for循环来解析结果集。但我不知道如何在for循环中添加项 样本:Actions on google 调用app.buildCarousel()时如何在for循环中迭代调用addItems,actions-on-google,Actions On Google,我想基于结果集在旋转木马中创建多个项目。我使用for循环来解析结果集。但我不知道如何在for循环中添加项 样本: app.ask(app.buildRichResponse() .addSimpleResponse("Alright. Here are the result") .addSuggestions(['Basic Card', 'List', 'Carousel', 'Suggestions']), app.buildCarousel() videos.forEach(functio
app.ask(app.buildRichResponse()
.addSimpleResponse("Alright. Here are the result")
.addSuggestions(['Basic Card', 'List', 'Carousel', 'Suggestions']),
app.buildCarousel()
videos.forEach(function(item){
.addItems(app.BuildOptionItem('${item.id.videoId}',['1', 'First one'])
.setTitle(item.snippet.title)
.setDescription(item.snippet.description)
.setImage(item.snippet.thumbnails.default.url, 'image'))
});
Try this.
const carousel = app.buildCarousel()
videos.forEach(function(item){
carousel.addItems(app.BuildOptionItem('${item.id.videoId}',['1', 'First one'])
.setTitle(item.snippet.title)
.setDescription(item.snippet.description)
.setImage(item.snippet.thumbnails.default.url, 'image'))
});
app.ask(app.buildRichResponse()
.addSimpleResponse("Alright. Here are the result")
.addSuggestions(['Basic Card', 'List', 'Carousel', 'Suggestions']),
carousel
);