I want to show items dynamically by using a for loop in CollectionBrowse. I'm using the code below, but actions on google returns an error when I use it.
const {
conversation,
Simple,
Card,
Image,
Button,
List,
Link,
Table,
CollectionBrowse,
Suggestion,
Schema
} = require('@assistant/conversation');
const functions = require('firebase-functions');
const app = conversation({debug:true});
app.handle('callApi', (conv) => {
conv.add(new CollectionBrowse({
items:[
{
title: 'Item #1',
description: 'Description of Item #1',
footer: 'Footer of Item #1',
image: {
url: 'https://developers.google.com/assistant/assistant_96.png',
},
openUriAction: {
url: 'https://www.example.com',
},
},
{
title: 'Item #2',
description: 'Description of Item #2',
footer: 'Footer of Item #2',
image: {
url: 'https://developers.google.com/assistant/assistant_96.png',
},
openUriAction: {
url: 'https://www.example.com',
},
},
{
title: 'Item #3',
description: 'Description of Item #3',
footer: 'Footer of Item #3',
image: {
url: 'https://developers.google.com/assistant/assistant_96.png',
},
openUriAction: {
url: 'https://www.example.com',
},
}
]
}));
});
exports.ActionsOnGoogleFulfillment = functions.https.onRequest(app);
I would like to change my code to something along the lines of the example below.
conv.add(new CollectionBrowse({
items:[
for(var i = 1; i < 4; i++){ <------------------------- i want it!!!!!!
{
title: 'Item #'+i,
description: 'Description of Item #'+i,
footer: 'Footer of Item #'+i,
image: {
url: 'https://www.example.com',
},
openUriAction: {
url: 'https://www.example.com',
},
}
}
]
}));
What should I do with the for loop statement, if not this way, is there another way?
Thank you.