Search code examples
botframeworkbot-framework-composer

How to create a multiline response in one message from json in microsoft bot composer?


I have a web api which gives me a list of people.

This is the list, requested it in Postman :

List of people

In my bot, I want to show this list to the user in ONE message.

When I use foreach it sends a message for each person.

Here is the bot composer :

enter image description here

And here is the result :

enter image description here

Following picture is what I expect : (hardcoded)

enter image description here

How can I do this in composer ?

Thank you.


Solution

  • Use something like this (this is for an order but it's conceptually the same) in the output templates:

    a template to format each item:

    # orderItem(x)
    - ```
    - ${x.name} ${x.qty}
    ```
    

    And then the template for the order:

    # OrderDetails
    - ```
    ORDER: **${dialog.order.number}**
    
    ${join(select(dialog.order.items, x => orderItem(x)), '\n')}
    
    ```