5

I'm trying out the slots feature in IBM Watson Conversations and have hit an issue which I'm not sure how to work around.

I have a use case that is collecting a number of pieces of information from a user so using the Slots feature makes sense. Unfortunately when I add a Slot with @sys-number the system will not accept 0 as a valid input. This slot is in fact required but 0 is a valid value.

Anyone have an idea of how to have a required Slot of type @sys-number that accepts 0 as a value?

Oliver Cox
  • 63
  • 6
  • Does the service recognize `0` as `@sys-number` when testing without slots? In my case it did. – data_henrik Jul 25 '17 at 12:04
  • Yes it does pick up on the `0` as `@sys-number` but doesn't appear to accept it as fulfilling the slot. – Oliver Cox Jul 25 '17 at 12:39
  • 1
    I think this question has already been answered. Please check https://stackoverflow.com/questions/43472182/ibm-watson-sys-number-does-not-get-0 – barbs Jul 25 '17 at 12:46
  • 3
    That's different as it refers to leading zeros also it isn't related to the Slots feature. I did search before posting :) – Oliver Cox Jul 25 '17 at 12:54
  • 1
    It seems different because the linked answer is for preceding zeros. Here it is about slot-related flows. The zero seems to be detected as number, but the slot flow does not react accordingly. – data_henrik Jul 25 '17 at 13:05
  • I have asked it in the WDC slack, looks like a bug to me https://wdc-community.slack.com/archives/C0A23B42U/p1500988243670249 (if you don't have an account, join here http://wdc-slack-inviter.mybluemix.net/) – data_henrik Jul 25 '17 at 13:26

2 Answers2

4

The condition @sys-number is in fact a short hand syntax for condition entities['sys-number'].value. When 0 is sent the condition is evaluated to false as 0 is treated as a false by the expression language evaluator in Watson Conversation Service. Now this is not a desired behavior in this case. To prevent this for happening one can use entities['sys-number'] in the condition that will return true every time @sys-number entity is recognized in the input.

When using this in slot one might want to edit what gets stored in the context variable as changing the condition will also change what is stored in the variable. This can be done by a JSON editor - click configure slot gear next to the slot specification and in the window that opens click three dots, open JSON editor and there change what gets actually stored inside the context variable that gets updated by the slot.

Here is a link to system entity section in Watson Conversation Service documentation.

Michal Bida
  • 1,316
  • 9
  • 24
  • 1
    Thanks Michal, confirmed as working with the slot condition as `entities['sys-number']` and the context variable set to `@sys-number` in the JSON editor for that slot. – Oliver Cox Jul 26 '17 at 16:15
3

I had a similar problem with recognising zero values in slots and the system entity documentation did not explain it well enough (for me at least).

Further elaborating on Michal's answer above:

  1. Click the "Edit Slot" option (gear icon)
  2. Set the "Check For" attribute on a slot condition as entities['sys-number']

edit slot modal

  1. Click the edit slot modal menu options (three bubbles in corner)
  2. Open the JSON editor
  3. Change the context variable value to "<?entities['sys-number'].value ?>"

edit slot json editor


Result:

result

Greg Byrne
  • 188
  • 1
  • 7