我需要在 Watson Assistant 对话节点中显示未知数量的按钮。按钮的数据来自 IBM Cloud Function。
如果我在节点中手动设置响应类型“选项”答案,则 JSON 对象如下所示:
{
"output": {
"generic": [
{
"title": "Välj mötestyp",
"options": [
{
"label": "Rådgivning familjerätt 30 min",
"value": {
"input": {
"text": "447472"
}
}
},
{
"label": "Rådgivning familjerätt 60 min",
"value": {
"input": {
"text": "448032"
}
}
}
],
"description": "Välj typ av möte du vill boka",
"response_type": "option",
"preference": "dropdown"
}
]
}
}
我的云函数可以使用 x 无选项创建此 JSON。但是如何在 Google 助理中使用这些数据?
最简单的方法是让云函数生成完整的 JSON,然后像这样输出返回的 JSON:
{
$context.output"
}
..但这是不允许的。
从我的函数生成的输出对象:
[{"serviceId":447472,"serviceName":"Rådgivning Familjerätt 30 min"},{"serviceId":448032,"serviceName":"Rådgivning Familjerätt 60 min"}]
关于如何做到这一点的任何建议?