3

I have a node in which I have enabled slots and within the node there are several slots. The first slot asks the customer to provide a specific number. After 3 unsuccessful inputs, I want the bot to automatically skip to the next slot. Is this possible?

Many thanks.

1 Answers1

3

Yes, you can exit or move on after a certain number of unsuccessful attempts of gathering information. This is done using the "Not Found" condition on slots and by adding a counter variable. Check out this example in the docs on "Moving on after multiple failed attempts".

That sample defines this counter (my recommendation: name it differently):

  "context": {
    "counter": "<? context['counter'] + 1 ?>"
  }

Then, in a "not found" condition, you would check $counter > 3. There, in the output and context section, set up another context variable to trigger skipping to a specific node.

data_henrik
  • 16,724
  • 2
  • 28
  • 49
  • Thanks a lot man, you are the king of this site ! I appreciate your help!!! – Ömer Kadıoğlu Sep 28 '18 at 08:25
  • By the way, I need to set the initial value of "counter" to 0, how can I do it? I have tried many ways but failed.. – Ömer Kadıoğlu Sep 28 '18 at 09:25
  • The docs suggest to set it in an earlier node. Another option could be to use the ternary operator (https://github.com/IBM-Cloud/watson-conversation-variables#conditions-and-predicates-in-the-response) and check if counter exists and increment, else set it to 0 – data_henrik Sep 28 '18 at 09:42