简体   繁体   English

IBM Watson Assistant:如何让聊天机器人响应动态选项列表

[英]IBM Watson Assistant: How to let the chatbot respond with a dynamic option list

I'm on IBM Watson Assistant Web Interface.我在 IBM Watson Assistant Web Interface 上。

I would like to add a possibility for the chatbot to respond with a list of options based on a variable.我想为聊天机器人添加基于变量的选项列表进行响应的可能性。 This variable will be filled by my backend.这个变量将由我的后端填充。 The variable will be like this :变量将是这样的:

$list: [

{"value": 443535, "label": "n°443535"},

{"value": 443536, "label": "n°443536"},

{"value": 443537, "label": "n°443537"}

]

So I can't use the basic interface.所以我不能使用基本界面。 在此处输入图片说明

I must use the JSON editor.我必须使用 JSON 编辑器。 在此处输入图片说明

But in it, obviously it's impossible to add data (with for example tag) of a type different from type "string".但是在其中,显然不可能添加与“字符串”类型不同的类型的数据(例如带有标记)。 What can I do ?我能做什么 ?

The JSON structure for an IBM Watson Assistant answer with options is documented.包含选项的 IBM Watson Assistant 答案的 JSON 结构已记录在案。 You would need to compose a JSON value based on that format and assign it to a variable, eg, myvar .您需要根据该格式组合一个 JSON 值并将其分配给一个变量,例如myvar

Now, in your dialog you would need to add that options array myOptionsArray to your output.现在,在您的对话框中,您需要将该选项数组 myOptionsArray 添加到您的输出中。 Assuming the array data is stored in the variable myvar, use something like this:假设数组数据存储在变量 myvar 中,请使用以下内容:

<? output.generic.addAll($myvar.myOptionsArray) ?>

The generic refers to the generic JSON output format - in contrast to the integrations JSON format.通用是指通用 JSON 输出格式- 与集成 JSON 格式相反。 The above expression could be placed in a response.上面的表达式可以放在响应中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM