public class SelectionCarousel implements HelperIntent
Helper intent response to collect user's input with a carousel.
Usage:
List items = new ArrayList<>();
CarouselSelectCarouselItem item;
for (int i = 0; i < 3; i++) {
item = new CarouselSelectCarouselItem();
item.setTitle("Item #" + (i + 1))
.setDescription("Description of Item #" + (i + 1))
.setImage(new Image()
.setUrl(IMAGES[i])
.setAccessibilityText("Image alt text"))
.setOptionInfo(new OptionInfo()
.setKey(String.valueOf(i + 1)));
items.add(item);
}
responseBuilder
.add("This is the first simple response for a selection carousel.")
.add(new SelectionCarousel().setItems(items));
The following code demonstrates how to get the user's selection:
@ForIntent("item selected")
public CompletableFuture itemSelected(ActionRequest request) {
ResponseBuilder responseBuilder = getResponseBuilder();
String selectedItem = request.getArgument("OPTION").getTextValue();
responseBuilder
.add("You selected: " + selectedItem);
return CompletableFuture.completedFuture(responseBuilder.build());
}
Constructor and Description |
---|
SelectionCarousel()
Helper intent response to collect user's input with a carousel.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getName() |
java.util.Map<java.lang.String,java.lang.Object> |
getParameters() |
SelectionCarousel |
setItems(java.util.List<com.google.api.services.actions_fulfillment.v2.model.CarouselSelectCarouselItem> items) |
getName, getParameters
public SelectionCarousel()
Helper intent response to collect user's input with a carousel.
Usage:
List items = new ArrayList<>();
CarouselSelectCarouselItem item;
for (int i = 0; i < 3; i++) {
item = new CarouselSelectCarouselItem();
item.setTitle("Item #" + (i + 1))
.setDescription("Description of Item #" + (i + 1))
.setImage(new Image()
.setUrl(IMAGES[i])
.setAccessibilityText("Image alt text"))
.setOptionInfo(new OptionInfo()
.setKey(String.valueOf(i + 1)));
items.add(item);
}
responseBuilder
.add("This is the first simple response for a selection carousel.")
.add(new SelectionCarousel().setItems(items));
The following code demonstrates how to get the user's selection:
@ForIntent("item selected")
public CompletableFuture itemSelected(ActionRequest request) {
ResponseBuilder responseBuilder = getResponseBuilder();
String selectedItem = request.getArgument("OPTION").getTextValue();
responseBuilder
.add("You selected: " + selectedItem);
return CompletableFuture.completedFuture(responseBuilder.build());
}
public SelectionCarousel setItems(java.util.List<com.google.api.services.actions_fulfillment.v2.model.CarouselSelectCarouselItem> items)
public java.lang.String getName()
public java.util.Map<java.lang.String,java.lang.Object> getParameters()