Azure Logic App fails with “InvalidTemplate” when parsing a Teams adaptive card response containing nested arrays

josh benut 0 Reputation points
2026-10-22T17:13:28.3633333+00:00

I’m building a Logic App (Consumption plan) that posts an adaptive card to a Teams channel and waits for a response. The card includes a multi-select input (Input.ChoiceSet with isMultiSelect: true). When a user selects more than one option, the next step fails with this error:

InvalidTemplate. Unable to process template language expressions in action 'Parse_JSON'.
The template language expression 'body('Post_adaptive_card_and_wait_for_a_response')?['data']?['choices']' cannot be evaluated because property 'choices' returned a string instead of an array.

With a single selection it works fine. With multiple selections, Teams returns the values as a comma-separated string (e.g. "opt1,opt2,opt3") rather than an array, so my Parse JSON schema, which expects "type": "array", fails.

What I’ve tried:

  • Changing the schema to "type": "string", which works but then I can’t loop over the values.
  • Using split(body('...')?['data']?['choices'], ','), which works for multi-select but breaks when a choice value itself contains a comma.
  • Setting the choice values to numeric IDs instead of text, which helps, but I’d like to know if there’s a cleaner approach.

Environment:

  • Logic Apps Consumption, West Europe
  • Connector: Microsoft Teams, “Post adaptive card and wait for a response”
  • Card schema version 1.4

My questions:

  1. Is the comma-separated string the intended behavior for multi-select Input.ChoiceSet in this connector?
  2. Is there a recommended way to handle values that may contain commas?
  3. Is there a way to get a proper array back without extra string handling?I’m building a Logic App (Consumption plan) that posts an adaptive card to a Teams channel and waits for a response. The card includes a multi-select input (Input.ChoiceSet with isMultiSelect: true). When a user selects more than one option, the next step fails with this error:
       InvalidTemplate. Unable to process template language expressions in action 'Parse_JSON'.
    

The template language expression 'body('Post_adaptive_card_and_wait_for_a_response')?['data']?['choices']' cannot be evaluated because property 'choices' returned a string instead of an array.

   
   With a single selection it works fine. With multiple selections, Teams returns the values as a comma-separated string (e.g. `"opt1,opt2,opt3"`) rather than an array, so my Parse JSON schema, which expects `"type": "array"`, fails.
   
   **What I’ve tried:**
   
      - Changing the schema to `"type": "string"`, which works but then I can’t loop over the values.
      
         - Using `split(body('...')?['data']?['choices'], ',')`, which works for multi-select but breaks when a choice value itself contains a comma.
         
            - Setting the choice values to numeric IDs instead of text, which helps, but I’d like to know if there’s a cleaner approach.
            
   **Environment:**
   
      - Logic Apps Consumption, West Europe
      
         - Connector: Microsoft Teams, “Post adaptive card and wait for a response”
         
            - Card schema version 1.4
            
   **My questions:**
   
   1. Is the comma-separated string the intended behavior for multi-select `Input.ChoiceSet` in this connector?
   
   1. Is there a recommended way to handle values that may contain commas?
   
   1. Is there a way to get a proper array back without extra string handling?
   
Azure Logic Apps
Azure Logic Apps

An Azure service that automates the access and use of data across clouds without writing code.

0 comments No comments

1 answer

Sort by: Oldest
  1. Allan Solomon Mejia 10,640 Reputation points
    2026-10-22T21:00:35.0133333+00:00

    Hello @josh benut

    Thanks for providing the details and the troubleshooting you've already performed.

    The behavior you're seeing is expected under the Adaptive Cards specification, not specific to the Azure Logic Apps Consumption plan or the Microsoft Teams connector.

    When Input.ChoiceSet has isMultiSelect: true, it returns the selected values as a comma-separated string, not a JSON array.

    1. Is the comma-separated response expected?

    Yes. For example, a multi-select ChoiceSet may return:

    {
      "choices": "opt1,opt2,opt3"
    }
    

    Your Parse JSON action fails because its schema expects an array, while the actual response contains a string.

    2. How should choice values containing commas be handled?

    The recommended approach is to separate the user-facing display text from the internal choice value.

    For example:

    {
      "type": "Input.ChoiceSet",
      "id": "choices",
      "isMultiSelect": true,
      "choices": [
        {
          "title": "Paris, France",
          "value": "paris_fr"
        },
        {
          "title": "London, United Kingdom",
          "value": "london_uk"
        },
        {
          "title": "New York, USA",
          "value": "new_york_us"
        }
      ]
    }
    

    The title can contain commas because it's the displayed label. The value should use a comma-free identifier.

    You can then map the selected identifiers back to their descriptive names later in the workflow.

    3. How can the response be converted into an array?

    In your Parse JSON action, define choices as a string:

    {
      "type": "object",
      "properties": {
        "choices": {
          "type": "string"
        }
      }
    }
    

    Assuming you're parsing the response's data object, add a Compose action with this expression:

    split(
      coalesce(body('Post_adaptive_card_and_wait_for_a_response')?['data']?['choices'], ''),
      ','
    )
    For a response containing:
    paris_fr,london_uk,new_york_us
    The resulting array is:
    [
      "paris_fr",
      "london_uk",
      "new_york_us"
    ]
    

    You can then use the Compose output in an For each action.

    One consideration: if no choice is selected, the expression above can produce an array containing an empty string. If an empty selection is allowed, handle that condition before splitting.

    4. Can the connector return a native array automatically?

    No documented setting in the Microsoft Teams Post adaptive card and wait for a response action that changes the multi-select ChoiceSet output into a native JSON array.

    The comma-delimited format is defined by Adaptive Cards itself, so changing the Parse JSON schema alone won't change the returned value.

    For this scenario, using comma-free choice identifiers followed by split() is the straightforward supported approach.

    Therefore, keep commas in the display labels if needed, but not in the underlying choice values. Parse the response as a string and convert it into an array using split() before processing the selected items.

    Hope this helps!

    References:


    Help make this community better for everyone: If this answer helped or resolved your issue, please accept it or upvote it. If not, share more details in a comment so we can continue the discussion and find the right solution. Thank you.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.