Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Value is not preserved across flow breaking commands #10

Open
aneilbaboo opened this issue Jul 4, 2017 · 0 comments
Open

Value is not preserved across flow breaking commands #10

aneilbaboo opened this issue Jul 4, 2017 · 0 comments

Comments

@aneilbaboo
Copy link
Owner

aneilbaboo commented Jul 4, 2017

In a flow which contains a flow-breaking command, such as the following, special returned value is not preserved across the break. Here, a break is created by invoking a dialog. Notice how the value returned by Dialog1 is lost after the break.

We should fix this.

onStart: [
  { start: "Dialog1", // returns "v1"         flowPath = [onStart,start(Dialog1)] 
    then: [  // value="v1"                    flowPath = [onStart,start(Dialog1),then] 

      // starting Dialog2 breaks the flow (Dialog2 starts a new flow)
      {  start: "Dialog2", // returns "v1"    flowPath = [onStart,start(Dialog1),then,start(Dialog2)] 
          then: [ // value="v2" here          flowPath = [onStart,start(Dialog1),then,start(Dialog2),then] 
          ]
      },
      // this is the nextFlow of the "onStart.start(Dialog1).then" flow
      "Value is {{value}}"  // expecting this to send message "Value is v1", 
                            // but bot sends "Value is undefined"
                          
    ]
]

One solution is to:

  1. Detect whether flow has a next flow
  2. If value is set in the flow, save it to a hidden variable before each flow breaker
    E.g., save value v1 in flow onStart.start(Dialog.then to a local session var, such as:
    "__value__:onStart.start(Dialog1).then" = "v1"
    This would happen just before {start: "Dialog2" ...}
  3. Load the value at the beginning of the nextFlow
  4. clear the value at the end of the last nextFlow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant