ibm-watsonwatson-conversation

IBM Watson Slots won't accept 0


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?


Solution

  • 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.