Digital Assistant and Mobile

Get Involved. Join the Conversation.

Topic

    Dejan Dragicevic
    Flow goes into infinite loop
    Topic posted November 19, 2018 by Dejan DragicevicGreen Ribbon: 100+ Points 
    584 Views, 12 Comments
    Title:
    Flow goes into infinite loop
    Summary:
    I want the user to choose an option and if it is not correct option to choose again.
    Content:

    Hello,

    i am new to Digital Assitant and am currently trying to learn the OBotML language so I am building
    a simple test skill to test transitions. 

    My test case is this: I have one intent (Start - utterances:Hi,Hello, Hey), entities (Options - values: Option 1, Option 2, Option 3). I want the user to choose an option.
    I check if the option is the one that I want chosen. If not..the user needs to choose again. 
    If it is...continue. 

    Problem: The flow goes into a infinite loop. 

    The dialog flow is in the code snippet. 

    I also tried first resetting the value of the variable, but same problem:


    main: true
    name: "Test"
    context:
      variables:
        Options: "Options"
        iresult: "nlpresult"
    states:
      Intent:
        component: "System.Intent"
        properties:
          variable: "iresult"
        transitions:
          actions:
            Start: "start"
            Stop: "stop"
    ###############################################           
      start:
        component: "System.List"
        properties:
          options: "${Options.type.enumValues}"
          prompt: "Please choose an option?"
          variable: "Options"
        transitions: {}
      conditionEquals:
        component: "System.ConditionEquals"
        properties:
          source: "${Options.value}"
          value: "Option 2"
        transitions:
          actions:
            equal: "done"
            notequal: "reset"        
    ##############################################
      reset:
        component: "System.ResetVariables"
        properties:
          variableList: "${Options.value}"
        transitions: {}
      isreset:
        component: "System.Output"
        properties:
          text: "i reset ${Options.value}"
          keepTurn: true
        transitions:
          next: "start"
    ##############################################
      done:
        component: "System.Output"
        properties:
          text: "You have chosen ${Options.value}."
        transitions:
          return: "done"
    ##############################################  
      stop:
        component: "System.Output"
        properties:
          text: "You have stopped the dialog flow."
        transitions:
          return: "stop"

    Version:
    Version 18.4.3-1811081905
    Code Snippet:

    Comment

     

    • Alvin John Margallo

      Hi -

      I think the problem is that your variable "Option" has already a value when going back to the next iteration of the loop.

      How the System.List and System.Prompts behave is that it will be skipped when the variable property is already set.

      Try, resetting the variable Option at the beginning.

      ############################################################

        reset:
          component: "System.ResetVariables"
          properties:
            variableList: "Options"
          transitions: {}

      start:
          component: "System.List"
          properties:
            options: "${Options.type.enumValues}"
            prompt: "Please choose an option?"
            variable: "Options"
          transitions: {}
        conditionEquals:
          component: "System.ConditionEquals"
          properties:
            source: "${Options.value}"
            value: "Option 2"
          transitions:
            actions:
              equal: "done"
              notequal: "reset" 

      ###############################################

      • Dejan Dragicevic

        Same thing. I already stated in my original message that i tried with resetting the variable. I followed your suggestion, put the variable reset at the beginning but still get a loop.

        • Alvin John Margallo

          Hi -

           Have you set the notequal to "reset" as well?

          Thanks!

          • Dejan Dragicevic

            Yes

            • Alvin John Margallo

              Hi Dejan -

                Works for me this way:

              Note: Sorry that I got lazy to create an Entity for the Option. But should behave the same way.

              ##################################################

               

               reset:
                  component: "System.ResetVariables"
                  properties:
                    variableList: "Options"
                  transitions: {}
                 
                start:
                  component: "System.List"
                  properties:
                    prompt: "Choose an option for setting the transition action"
                    options:
                    - label: "Action 1"
                      value: "Option 1"
                    - label: "Action 2"
                      value: "Option 2"
                    variable: "Options"
                  transitions: {}

                conditionEquals:
                  component: "System.ConditionEquals"
                  properties:
                    source: "${Options.value}"
                    value: "Option 2"
                  transitions:
                    actions:
                      equal: "done"
                      notequal: "reset"       

                done:
                  component: "System.Output"
                  properties:
                    text: "Done"
                  transitions:
                    return: "done"

                     

    • Frank Nimphius

      Hi,

       

      you don't reset your "iresult"variable. So keepTurn=true on the last output components causes the infinite loop. Either reset iResult or use keepTurn: false

       

      Frank

    • Laban Ndwaru

      Hello Dejan,

      As Frank mentioned, you have two options, reset the iresult variable or set keepTurn: false,

      Here is a working code with where the iresult variable is reset.

      metadata:
        platformVersion: 1.0
      main: true
      name: "LNCommunityTest"
      context:
        variables:
          Options: "Options"
          iresult: "nlpresult"
      states:
        Intent:
          component: "System.Intent"
          properties:
            variable: "iresult"
          transitions:
            next: "start"
            actions:
              Start: "start"
              Stop: "stop"
              
       ###############################################
        start:
          component: "System.List"
          properties:
            options: "${Options.type.enumValues}"
            prompt: "Please choose an option?"
            variable: "Options"
          transitions:
            next: "conditionEquals"
        conditionEquals:
          component: "System.ConditionEquals"
          properties:
            source: "${Options.value}"
            value: "Option 2"
          transitions:
            actions:
              equal: "done"
              notequal: "stop"   
       

      #############################################

        done:
          component: "System.Output"
          properties:
            text: "You have chosen ${Options.value}."
          transitions:
            return: "iresult"
      ##############################################  


        stop:
          component: "System.Output"
          properties:
            text: "You have stopped the dialog flow."
          transitions:
            next: "iresultReset"

      #####Reset the iresult value #############
        iresultReset:
          component: "System.ResetVariables"
          properties:
            variableList: "iResult"
          transitions:
            next: "start"  
            
            
            
           More tips: try to avoid "transition: {}", instead have a next state.

      Laban.


            
           

       

       

      • Dejan Dragicevic

        I copied your dialog flow. This doesn't work either: http://prntscr.com/llij0a

        It just outputs the text: "You have stopped the dialog flow" and stops there..

    • Frank Nimphius

      Well, it works for me. Copied and pasted the code and run it. By issuing a return statement, the next step in the flow - when the use enters a new string is the intent state

      Frank

       

       

       

      • Dejan Dragicevic

        I did the same and the flow just stops, as you can see on the screenshot: http://prntscr.com/llij0a . I am not sure what you mean by "issuing a return statement". What i want after the condition is for this part to be run again:

         start:
            component: "System.List"
            properties:
              options: "${Options.type.enumValues}"
              prompt: "Please choose an option?"
              variable: "Options"
            transitions:
              next: "conditionEquals"

        So the user is asked again to choose an option...   but the flow stops and doesnt come to this part.                                  

    • Frank Nimphius

       

      Actually what I mean by "issuing a return statement" is that instead of "next" the sample used "return" which will by the next user request start at the beginning. However, changing it also worked. So I think next step for you is to upload your test case by exporting the bot for me to try.

       

      Frank