Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

ibm cloud - Watson Assistant Context Variable Counter 2021

I know this has been asked multiple times in the past but the code seems not to work for me and I think Watson interfaces changed a lot since 2017 :(

I want to add a counter to a multiple conditioned responses node. After the 3rd time asking the same question the bot should jump to another node.

At welcome I created a context Variable: counter with value: 0

Screenshot 1

At the multiple conditioned responses node I set a context variable for each answer. Variable: counter Value: "<? $counter + 1 ?>"

Screenshot 2

But instead of updating the value number of counter to 1 it updates the value to "['counter'] + 1" The computation doesn't work. So how can I solve this?

Screenshot 3

If the computation would work, I would add another conditioned response and let Watson check for: $counter > 3 and if that true it would jump to another node.

Would be very thankful for any advise :)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

My suggestion is to handle the computations by editing the dialog node in JSON. You probably know this, but else see this section on how to access objects in Watson Assistant. Make sure the assignment is performed in the context section.

Your code should work to increase the counter by one:

<? $counter + 1 ?>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...