我正在调用 http 服务,它返回 json 中的对象数组。在 Bot Framework Composer 中,我使用 For each 循环来迭代数组。对于数组的每一项,机器人都需要向用户提问。问题的文本来自收到的项目数组。
在机器人模拟器中运行,机器人问第一个问题,但不问任何后续问题。如何让它为每个返回的数组项提出一个问题?
从 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?"
}
]
机器人作曲家代码:
{
"$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"
}