VoiceAssist on cloudLink (ForEach activity )

Dear All,
could you explay me better the details to “how to” setup the ForEach configuration?
I need to configure For_Each1 task; where do I have to configure this parameter? And what is the exact “Condition” item sintax in the Work Flow.
I wish to check a body response, where more than of one item is returned.
ex. the http request is http://my.ipserver:9300/users?code=1971
the body response returns multiple name objects like this in json format
[
{
“id”: 1,
“name”: “Walter”,
“code”: 1971,
“city”: “Bresso”
},
{
“id”: 2,
“name”: “Lucy”,
“code”: 1971,
“city”: “Vignate”
},
{
“id”: 3,
“name”: “Giulia”,
“code”: 1971,
“city”: “Melzo”
}
]

or like this in array format
"[{\"id\":1,\"name\":\"Walter\",\"code\":1971,\"city\":\"Bresso\"},{\"id\":2,\"name\":\"Lucy\",\"code\":1971,\"city\":\"Vignate\"},{\"id\":3,\"name\":\"Giulia\",\"code\":1971,\"city\":\"Melzo\"}]"

And I want to compare the item name as “Lucy”, if exists in this array.

Please could you show me with screenshot, where these parameters (For_Each1) must be insert?
Each cooperation will be very appreciate
Thankyou
BR
Walter

Hi Walter,

When you add the HTTP activity, by default it will be named Http_Request1, so the array of results that it returns can be referred to as Http_Request1.Body.
To set up a ForEach activity that goes through the array of results returned by the HTTP activity, you can do the following:

  • Add a ForEach activity after the HttpRequest activity, and enter Http_Request1.Body as the array value to search as shown here:
    image
  • As you iterate through the array, each item will be referred to as For_Each1.Item
  • Inside the brackets of the ForEach activity, add a comparision to check if `For_Each1.Item.name == ‘Lisa’ as shown here:
  • After the Match condition, you can take any action you would like.

The end workflow should look similar to this:

If you have any additional questions, just let us know.
Thank you.

Dear Pamaelliot you have done goal!!!
In my WF is not present the option “For Each” item.
In the picture the only option I can find

Please let me know I have to do to insert the “For Each” item, as in your image.

Thank you
Waletr

Hi Walter,
My apologies - I didn’t realize that the ForEach activity is not available in Voice Assist. We can accomplish what you would like to do by searching within the array results using a condition. I will test that out and then reply back with the updates for your workflow.

Thanks,
Pam

Hi Walter,

We can accomplish the same search function by doing the following:

  • After your HttpRequest activity, add a Set Variables activity, which is setting the testobj variable to the return value with the name set to Lucy. Make sure it is an expression, with the value set to the following, as shown below: ArrayFind(Http_Request1.Body, ‘name == \“Lucy\”’)
    Note that you need to add a \ character before each double quote around Lucy
    image

  • If a return value with Lucy is found in the HTTP response, it will be contained in the testobj variable. Otherwise, the value will be null. You can add a Condition to check testobj.name after the SetVariables activity.

I hope this helps! Let me know if any questions.

Hi Pam,
great!!
All works fine now. Very well.
Just one more question (my curiosity).
What kind of tool you have used in your previos image where there were the “ForEach” item?
Is it another kind of PBX integration?
That’s only for my information.
Thank you
Walter

Hi Walter!

That screenshot was of Workflow Studio, which is the UX for the Workflow service that Voice Assist is built on top of. Right now you can access a limited version of Workflow in order to configure Voice Assist, but in the future (next year) we plan to roll out Workflow Studio for our partners. This will give you access to additional features and functionality such as the “For Each” activity.

Hi Bud,
thanks a lot for the expalnation.
then let’s wait for the “new year” :slight_smile:

Regards
Walter