Loops are always good, to allow the use of arrays with dynamic length.
Currently it is only possible to interact with elements in an array, that has a predefined length.
Just imagine you ask your customer for multiple appointments in a slot. Now you could use forEach on sys-date.values to change every date format and save it to context like this:
"appointments": "<? @sys-date.values.forEach(val => val.reformatDateTime('dd.MM.jjjj')) ?>"
Then you can print the array with $appointments.join(', ') anywhere in dialog in the correct format.
I also added this idea, that allows customers to add an dynamic amount of pizzas to one order: https://ibm-data-and-ai.ideas.aha.io/ideas/ASSISTANT-I-220
Looping through the pizzas array for further processing would be great.
Please implement the support for iterator().forEachRemaining() or forEach() on JSONArrays.
It would make the use of arrays much easier and allow developers to use dynamic customer data.
Why is it useful?
|Who would benefit from this IDEA?||Every Watson Assistant Developer and Customer|
How should it work?