0

I would like to know how you can sort the OptionItems in the list of Google DialogFlow. It seems that they are automatically sorted by the key of their OptionItem. I just want them displayed on the list in the order I push them in the list, so no auto-sorting would be best.

I got following code how I create an OptionItem:

const optionItems:{[key: string]: OptionItem} = {}

optionItems[outlet.outlet_id] = {
    synonyms: [
        outlet.outlet_id,
    ],
    title: outletOptionItemTitleText,
    description: outletOptionItemDescriptionText,
    image: {
        url: outletOptionItemImageUrlText,
        accessibilityText: outletOptionItemImageAccessibilityTextText,
    },
}

The optionItems are passed as parameter to the List Object of Google DialogFlow like below:

conv.close(showAvailabilityText,new List({
    items: optionItems,
}))

Can I pass another parameter to influence the order of the list? Or anything else?

Johannes N
  • 265
  • 3
  • 17
  • What about sorting it when you receive the request? You can choose whatever sorting method you want. https://stackoverflow.com/questions/13304543/javascript-sort-array-based-on-another-array – German Casares Aug 19 '19 at 16:21
  • This is how I try it at the moment. I also changed the sorting order to reverse, but Google DialogFlow sort the items automatically everytime according to their ID. – Johannes N Aug 20 '19 at 08:25

0 Answers0