Skip to content

Value is not preserved across flow breaking commands #10

Description

@aneilbaboo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions