简体   繁体   中英

IBM Chatbot Assistant: Handling Multiple Entities

I have an entity called @spare_part and this entity has 4 values with the following example synonyms each:

both with synonyms filter , oil level indicator

not_defined with a synonym spare part

only_gear with synonyms valve , seal

whole_gear_box with a synonym complete set of gearbox

I want to be able to handle multiple entities given in the same input and address them later on, if needed. With this purpose I have coded the following in JSON editor:

{
"context": {
"sparepartrequest": "@spare_part.values"
},
"output": {
"generic": [
  {
    "values": [
      {
        "text": "You want an offer for the following parts: <? 
  $sparepartrequest.join(', ') ?>."
      }
    ],
    "response_type": "text",
    "selection_policy": "sequential"
  }
  ]
  }
  }

I have created a context variable called sparepartrequest as can be seen from the code lines above. For instance when the user says "I want an offer for a filter and a seal", the output of the bot is the following sentence:

You want an offer for the following parts: both, only_gear.

I don´t want the bot to prompt back the names of the values of the entity @spare_part , I rather want it to store the exact input of the user, for our case which would be filter and seal . So if the bot worked as I wanted it to, the output would look like the following:

You want an offer for the following parts: filter, valve.

Again, I believe that this can be handled with JSON Editor. Thank you !

Use two context variables. sparepartrequest as already done and sparepartrequest_literals as follows:

"sparepartrequest_literals":"<? entities['spare_part'].![literal].join(', ') ?>" .

Then, in your text response call it by $sparepartrequest_literals to print the mentioned parts or use $sparepartrequest to refer to the detected values.

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