简体   繁体   中英

IBM Watson Assistant: Trying to evaluate and compare multiple context variables

I've just started trying out Watson Assistant and have no clue what I'm doing. I'm trying to built a chatbot that asks a series of questions and then outputs an evaluation based on the user's inputs.

Eg Inputs:

Q1 "How many apples do you have?"

Q2 "How many apples does your neighbour have?"

Q3 "Did you eat any apples?"

With my desired output as:

IF ((Q1 > Q2) AND Q3 = "No") 
  THEN output "You have more apples"
ELSEIF ((Q1 > Q2) AND Q3 = "Yes")
  THEN output "You might not have more apples"
ENDIF

I've currently used slots to collect all the inputs in one node but I don't know how to evaluate them to give the correct outputs.

In Watson Assistant inside the skill / dialog editor, you can edit the responses. For a response it is possible to contain expressions. The documentation for Watson Assistant has a section on Expression anguage methods and on Expressions for accessing objects . I have several examples in this GitHub repo Watson Conversation Variables which demonstrate how to evaluate the context variables and produce and output like you want.

Look here on how to use the ternary operator .

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