So you have a Dynamic List and you want to present a subset of that list, but won't know how big the subset will be.
I assume you want to present cards in messenger chat to the customer? Not have them enter the date. (I believe the max is 9 or 10 that can be displayed)
But if you want to break it up further:
Of the top of my head would be something like:
Create a reusable task.
And use a loop to populate the display list.
Loop where max loops == count of Dynamic list - So it will only ever go through the total Dynamic list never more.
Then just add to your display list the value GetAt(Task.Dynamiclist, Task.LoopIndex) - So always adding the current Dynamic List item being looped through.
if Task.LoopIndex == 4 then or Task.LoopIndex == 9 add "Other Date"
Then at then end, do an if the loop index +1 == Count of dynamic list, End Task and go down a completed exit path for the task, otherwise End task going to a different exit path eg more loop path.
On the more loop path just call the same reusable task, passing the LoopIndex back in so the loop knows where to kick things back off from.
If I get some time I'll try to create a dummy flow doing this, but the above is the gist of it.
------------------------------
Anton Vroon
------------------------------
Original Message:
Sent: 08-24-2022 12:57
From: Clayton Curtis
Subject: Dynamic list build in Messenger Bot
Thanks much for the code..this is good. However, and correct me if I am wrong, this presents all the values that come back. In my ideal scenario, assume it get 10 dates back from my search. I want to show the first 4 dates and an "other date" option. If they select other date, it would show dates 5-8, then 9 and 10 if they selected other again. is that possible?
------------------------------
Clayton Curtis
Enova Online Services, Inc.
Original Message:
Sent: 08-23-2022 12:54
From: Marc Sassoon
Subject: Dynamic list build in Messenger Bot
I have attached a CSV to create a Data Table, a Data Action to consume it and a Bot and Messaging Flow to use it all. Hopefully that helps.
------------------------------
Marc Sassoon
Genesys - Employees
Original Message:
Sent: 08-23-2022 12:49
From: Clayton Curtis
Subject: Dynamic list build in Messenger Bot
I think i follow but would love an example to get me on track. thanks so much for this advice!
------------------------------
Clayton Curtis
Enova Online Services, Inc.
Original Message:
Sent: 08-23-2022 12:19
From: Jane Hendricks
Subject: Dynamic list build in Messenger Bot
The advise is to not use MakeList code to generate a list. You need a Data Action that returns the dates as an Array of values and don't use MakeList to turn it into an array.
The data action returns one pair arrays (the eligibleDates in this case and any synonyms you want) and then the Data Action is called in the Bot Flow. The Bot Flow will use the mapped key (eligibleDates) to create the slot list for you and display it
------------------------------
Jane Hendricks
Genesys - Employees
Original Message:
Sent: 08-23-2022 11:19
From: Clayton Curtis
Subject: Dynamic list build in Messenger Bot
I am getting anywhere from 1 to 10 values back from a back end database api all (data action). I am trying to show these values to my customer via dynamic slot. However i don't know the exact number of values i will get back. Here was current code when I knew we were getting 4 values back consistently.
MakeList(Flow.eligibleDates_String[0], Flow.eligibleDates_String[1], Flow.eligibleDates_String[2], Flow.eligibleDates_String[3], "Choose Other Date")
But if i only get 1 value back, this code fails. Was trying to think of something like i +1, etc. but can't work it out. Any thoughts on how to have makeList perform dynamically based on undetermined set of results from api call.
thanks, Clayton
#ArchitectureandDesign
#Implementation
------------------------------
Clayton Curtis
Enova Online Services, Inc.
------------------------------