title: IBM Watson Assistant: How to set a 'jump to' target node dynamically (i.e. using context variables)
body: <p>I want to jump from a dialog node to a node the ID of which is stored in a context variable.</p>
  
  <p>I'm trying to solve a problem that has to do with a digression and which has been described here:</p>
  
  <p><a href="https://stackoverflow.com/questions/50609370/conditionally-return-from-digression-in-watson-assistant">Conditionally return from digression in watson assistant</a></p>
  
  <p>Especially this chart visualizes the problem:</p>
  
  <p><img src="https://i.stack.imgur.com/I6qOg.jpg" alt=""></p>
  
  <p>In my opinion, A.H. posed a very reasonable and relevant question that has got no viable answer.</p>
  
  <p>As far as I can see the problem can not be solved by digression settings. Either the root level node (triggered by matching the intent # Want_to_speak_to_someone) is set to 'return after digression' or it is not.</p>
  
  <p>If the digression setting of this digression node is set to 'return' it will always return - no matter what happens further down in the dialog flow of this digression. Even if the user confirms that he wants to speak to a person (i.e. he does not want to return) the dialog will return to the node where the digression started.</p>
  
  <p>This even happens when I jump from the yes-node (user confirms that he wants to speak to a person) out to any other node. As soon as the branch (or the branch the user jumped to) ends the dialog returns to the node where digression started. </p>
  
  <p>If the digression setting of this digression node is set to 'does not return' however, a return is not possible - even if the user decides against speaking to a person and opts for returning to where he was.</p>
  
  <p>What A.H. and I want is that the user can digress from a dialog flow and can still decide whether he wants to return or not. I think this is a pretty natural and important feature of a dialog. People like to reverse their decision or maybe they even digressed unintentionally from the given dialog flow.</p>
  
  <p>Akaykay proposed to have two different nodes - a 'yes-node' which allows returning and a 'no-node' that does not allow returning. But this doesn't work, because before that I must have another node that asks the user for confirmation - and this 'confirmation-node' has to be set either to 'return' or 'does not return' (yielding the problems described above).</p>
  
  <p>For this reason, I tried to figure out a workaround: I store the dialog node ID from which the dialog digresses in a context variable.</p>
  
  <p>It is a context variable</p>
  
  <pre><code>
  "context": {
          "last_node": "&lt;? output.nodes_visited [0]?&gt;",
          ...
        },
  
  </code></pre>
  
  <p>which gets updated in every node of a dialog flow which allows digression.</p>
  
  <p>In the example I could then jump back to the $last_node if the user wants to return and I could jump to another (fixed) node if the user wants to speak to a person - digressions settings of the 'digression node' would not interfere and could be set to 'does not return'.</p>
  
  <p>Then I tried to edit the respective node (from which to return to the $last_node) in the json file of my skill:</p>
  
  <pre><code>"next_step": {
          "behavior": "jump_to",
          "selector": "user_input",
          "dialog_node": "$last_node"
        },
  </code></pre>
  
  <p>But when I reimport the skill-json-file again I get this error message:</p>
  
  <p><a href="https://i.stack.imgur.com/0IaPS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0IaPS.png" alt="Error - we could not import your skill. Can only contain word, underscore, space, ..."></a></p>
  
  <p>I would be fine with either solution - one that uses digression settings or one that allows setting the 'jump to' target node dynamically. I deeply appriciate any help - thanks!</p>