我希望互动看起来像这样:
目前,我已经对人口进行了硬编码,如下所示:
{
"context": {
"inputcountry": "<?@Country?>",
"populations": {
"USA": "300M",
"Mexico": "100M",
"Japan": "127M"
}
},
"output": {
"text": {
"append": true,
"values": [
"The population of $inputcountry is approximately $populations.$inputcountry"
]
}
}
}
使用用户输入作为标识符/查找来提供特定人口编号的语法是什么?
使用$ population。上面显示的$ inputcountry返回
{"USA": "300M","Mexico": "100M","Japan": "120M"}.Mexico
答案 0 :(得分:4)
尝试<? $populations.get($inputcountry) ?>
- 这应该可以解决问题。
答案 1 :(得分:0)
您可能需要为它编写多个对话..
First dialogue triggering Condition: input.text.matches('USA')
Response: "The population of $input is approximately $populations.USA"
Second dialogue triggering Condition: input.text.matches('Mexico')
Response: "The population of $input is approximately $populations.Mexico"
Third dialogue triggering Condition: input.text.matches('Japan')
Response: "The population of $input is approximately $populations.Japan"
(任何对话节点都可以访问上下文变量)
另一种选择是将日本,美国,墨西哥作为实体。