Open iamrahulmaru opened 5 years ago
Have you tried adding an if condition that sends a BasicCard instead of a List when the list's length is 1?
yes i have tried it but after that i can't get click event of that. like below
app.intent('actions.intent.OPTION', (conv, params, option) => {
let response = 'You did not select any item';
if (option && SELECTED_ITEM_RESPONSES.hasOwnProperty(option)) {
response = SELECTED_ITEM_RESPONSES[option];
}
conv.ask(response);
});
That's an interesting point. If there is only one item, how much do you need to rely on user interaction? Maybe you adapt the flow more like this:
I found one item, Title. Do you want to hear it? User: Yes same fulfillment as selecting item
versus
I found 3 items. Which one do you want? User: Click
@Fleker that could be a possible solution. but I think Actions on Google should remove validation of minimum 2 items in the list. Only one item should be allowed. It will be easy & convenient for both users & developers.
and there is a maximum limit of 30 items in one list. What should we do when we have more than 30 items to show in one item?
You should splice the list and ensure that you have a maximum of 30 items.
You should splice the list and ensure that you have a maximum of 30 items.
that I know... but what if I have more than 30 items... what should we do in that case?
If you have more than 30, you should either splice the array so you show 30, or do some sort of pagination system. But if you have more than 30, a carousel is probably not the right UI for your use case.
Google should remove that validation of minimum 1 and maximum 30 (or give at least 50). Just a suggestion :)
If you only have one item, is there a time when you'd want to show that one item instead of just passing through and showing the value of that item?
I just did that and it worked. I put it in a function and return all the results.
var count = obj.resultCount;
var data = obj.results;
if (count > 1){
// your list code here
} else {
conv.ask(new BasicCard({
text: data[0].description, // Note the two spaces before '\n' required for
// a line break to be rendered in the card.
subtitle: data[0].releaseDate,
title: data[0].title,
buttons: new Button({
title: 'This is a button',
url: 'https://assistant.google.com/',
}),
image: new Image({
url: data[0].image,
alt: data[0].title,
}),
display: 'CROPPED',
}));
}
But now, how to make it cliquable like a list and get all infos ???
What should we do when we have only one item to show in List of actions on google rich response.
Actually, I am printing dynamic items in List. But when there is only one data it gives error.