简体   繁体   中英

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

I'm on 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. 在此处输入图片说明

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. You would need to compose a JSON value based on that format and assign it to a variable, eg, myvar .

Now, in your dialog you would need to add that options array myOptionsArray to your output. Assuming the array data is stored in the variable myvar, use something like this:

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

The generic refers to the generic JSON output format - in contrast to the integrations JSON format. The above expression could be placed in a response.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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