Displaying values from Json array into bot dialog

hello,
I have this response from an API that I’m triggering into the Api section into fresh bot designer.
Is there a way to list all the values like in a list or similar with all the values that are inside of each position of the array?

In some other dialogs I’m doing name.0.value to display the value of name on position 0 but in some cases I wan to show all the results in a dialog If I do result does not show anything .

@Sachin_Kumar already helped me on this previous thread.

image

thanks!

Hi @dtorres265,

You can pass result.{key} in a button or a dropdown, automatically the values will be populated for you to select.

Can you please share what kind of data will you be showing in the bot?

1 Like

hello,
the thing is that the results vary from the amount of data that a customer has so can return more than one array as showed in the image, and in some cases I want to display all of the results.

like result.0.contract
result.1.contract
and so on.
My question is how can I display all of the values if are more than one into the bot response?
hope I was clear enough!
thanks.

@dtorres265

I don’t think the bot supports looping today. What I have done in the past is if there are lets say 4 max options, I will check in conditions if result.1.contract=null, go to a dialog which only has the result.0.contract placeholder.

If result0 and result1 = not null but result2 = null, go to a dialog which displays results and result1

Its a workaround till the product supports looping through the values. And it isn’t scalable, works with 4-5 max options

1 Like

hello,
ok will tra y to setup something and check on this but it’s a valid workaround for now.
Anyway I was thinking that If I do display in the dialog with lets says result.0 till 10 the ones that are null will not display anything right? and the ones that has values will display it is that right?
So we can say that we display till a maximum of 10 contracts per customer which is very rare for insurance that a customer has more than 2 or 3 .

thanks again.

hello @adarsh I’ve tried by asking for not null and is not working as expected

I’ve like this

so I’m doing into the dialog conditions this
image

I’ve also tried for a specific value into a specific field, asked if it’s ’ ’ (empty) for example result.0.contract equals ’ '.
Could you please let me know if you think a better way so I can accomplish this?

The idea is to ask if the next element if present so I display it and if it’s not I jump to a different dialog.

thanks
dt

Hello @dtorres265

Can you please try with condition request[0].contact not equals ""

1 Like

I was able to make it work, thanks a lot for your guidance!

This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.