Search code examples
jsonnode.jssails.jsibm-watsonwatson-conversation

In watson conversation how to extract multiple values entered in input text


Iam working on an application where I display products in my inventory based on the user's "price range"..

I need to know how to extract the values (prices) entered in the input text.

I tried using the system entities @sys-currency & @sys-number but I can extract only one value(the first value)..

example:

the user asks to "display products between $200 and $500"

how can i extract both the values to be compared with the individual products prices and display relevant products..

suggestions appreciated..


Solution

  • In the node in watson conversation you can access entities as array. In your case it will be:

    Currency 1: <? entities['sys-currency'] != null && entities['sys-currency'].size()> 0 ? entities['sys-currency'][0].value : "---" ?>; Currency 2: <? entities['sys-currency'] != null && entities['sys-currency'].size()> 1 ? entities['sys-currency'][1].value : "---" ?>
    

    You need to add proper null checks and checks if array has more that one entered currency