Bot Framework Composer:遍历对象数组在json中会产生无效的输出

问题描述

我正在调用http服务,该服务返回json中的对象数组。 在Bot Framework Composer内部,我使用For Each循环对数组进行迭代。 对于阵列中的每个项目,机器人都需要向用户提问。 问题文本来自收到的项目数组。

在bot模拟器中运行时,bot会询问第一个问题,但不询问任何后续问题。 如何让它对每个返回的数组项提出问题?

从http服务返回的JSON:

 "questions":[
        {
            "question_id":"78jha873_q1","text":"What is question 1?"
        },{
            "question_id":"78jha873_q2","text":"What is question 2?"
        },{
            "question_id":"78jha873_q3","text":"What is question 3?"
        },{
            "question_id":"78jha873_q4","text":"What is question 4?"
        },{
            "question_id":"78jha873_q5","text":"What is question 5?"
        }
    ]

Bot Composer design

Bot Emulator runtime - asking questions

Bot Composer代码

{
              "$kind": "Microsoft.Foreach","$designer": {
                "id": "49MVnl"
              },"index": "dialog.foreach.index","value": "dialog.foreach.value","actions": [
                {
                  "$kind": "Microsoft.TextInput","$designer": {
                    "id": "yr2RbY"
                  },"disabled": false,"maxTurnCount": 1,"alwaysPrompt": false,"allowInterruptions": false,"prompt": "${TextInput_Prompt_yr2RbY()}","property": "turn.userAnswer"
                },{
                  "$kind": "Microsoft.SendActivity","$designer": {
                    "id": "ehxqn9"
                  },"activity": "${SendActivity_ehxqn9()}"
                }
              ],"itemsProperty": "dialog.my_api_response.reasoning.questions"
            }

解决方法

回答我自己的问题: 在For-each循环中,在Bot Asks活动中的“其他”选项卡下,将“始终提示”属性设置为true。