Search code examples
ibm-watsonwatson-conversation

Can I use the context variables in the conditions for the nodes in the dialog flow in the Watson Conversation?


Can I use the context variables in the conditions for the nodes in the dialog flow in the Watson Conversation?

In the case I try it:

if condition: context.variable !== 'undefined' the conversation will flow, else, the conversation will show some text.

How do it?

I try it:

See

And the conversation does not flow... and the intent flow to intent.confidence < 0.3 i've created

Obs.: My context.variablee just get some Data with regex, if user dont type correct, the conversation flow will display another message.


Solution

  • The main issue may be with your regex. You have a dangling * at the end. It should be:

      "context": {
        "xxx": "<? input.text.extract('^[^\d].*?[\d]{11}.*?$',0) ?>"
      },
    

    Before the variable is check you can use the following condition.

    input.text.matches('^[^\\d].*?\\d{11}.*?')
    

    When checking to see if the variable is set, you only need to have a condition as follows:

    $xxx
    

    Sample conversation script: http://pastebin.com/HuCJckry