根据返回的JSON更新上下文变量

时间:2020-09-23 11:05:15

标签: ibm-watson watson-assistant

我需要根据从我的API返回的JSON更新watson助手中节点的JSON。

示例:我助手的一个节点的响应显示了一个选项列表,下面的JSON创建了该选项列表。

{"output": { "generic": [ { "title": "aaaaa", "options": [ { "label": "aaaaa", "value": { "input": { "text": "a" } } }, { "label": "bbbbb", "value": { "input": { "text": "b" } } } ], "response_type": "option" } ] } }

我需要更改此JSON并放入来自我的API的JSON,下面是JSON的示例。

{"output": { "generic": [ { "title": "Relação de Cidades", "options": [ { "label": "São Paulo", "value": { "input": { "text": "SP" } } }, { "label": "Rio de janeiro", "value": { "input": { "text": "RJ" } } }, { "label": "Bahia", "value": { "input": { "text": "BA" } } } ], "response_type": "option" } ] }, "context": {} }

或者我可以将从API返回的JSON直接发送到对话中,以便它组合JSON创建的选项列表...吗?

我尝试将JSON放入变量中,并在对话中显示该变量的内容,但它显示的是JSON的内容,而不是组装JSON定义的列表。

结果如下。我是这样的:

enter image description here

感谢您的帮助,因为在互联网上找不到任何可以帮助我解决该问题的材料。

1 个答案:

答案 0 :(得分:0)

您可以将其作为上下文变量返回,然后在另一个上下文变量中引用该上下文变量。

将所需的自定义设置为$ Variable1

然后在您的上下文变量中只需将值指定为$ Variable1

相关问题