eniagreen / botml

Powerful markup language for modern chatbots.
https://codename.co/botml
MIT License
100 stars 20 forks source link

how does 'return' work from conditionals? #48

Closed dcsan closed 4 years ago

dcsan commented 5 years ago

sometimes when a conditional matches a response, the conversation will seem to return and continue. but other times it does not. I can't quite figure out the logic.

given this example

on bubbles

~ start
< start
  [intro]
~ [colors]
~ [ending]

~ colors
< Whats your favorite color?
---
  > red
  < roses are red
---
  > blue
  < sky is blue
---
> *{color}
< you like $color

= intro
- Let's begin

~ ending
< Thanks and goodnight.

> reset
~ [start]

image

dcsan commented 5 years ago

as in the above example, if the match is in one of the conditions it will not 'return'

---
  > red
  < roses are red

but if the reply is caught as the default/bottom entry of the logic block, then the code will return and continue, it seems.

---
> *{color}
< you like $color

image

dcsan commented 5 years ago

perhaps things would be better if there was a more explicit @ return or some type of keyword like that?

arnaud commented 5 years ago

You'll find the reasoning behind conditional, and some examples, in this post: https://github.com/codename-co/botml/issues/42#issuecomment-518370648

The only way I can think of right now, for addressing your example, would go like this:

~ start
< start
  [intro]
~ [colors]
~ [ending]

~ colors
< Whats your favorite color?
> *{color}
< you like $color
\`\`\`
if ($color === 'blue') {
  context.say('sky is blue')
}
\`\`\`

= intro
- Let's begin

~ ending
< Thanks and goodnight.

> reset
~ [start]

▶ Play this script

codenametype commented 5 years ago

Hi! Sorry for the very late response. According documentation Conditional branching please look on the last example and "jump_to" feature you could jump from a condition to the end of current dialogue. ▶ Play this script

Example:

~ start
< start
  [intro]
~ [colors]
~ [ending]

~ colors
< Whats your favorite color?
> *{color}
---
  ` /red/.test('$color')
  < roses are red
  ~ [end]
---
  ` /blue/.test('$color')
  < sky is blue
  ~ [end]
---
< you like $color
~ end

= intro
- Let's begin

~ ending
< Thanks and goodnight.

> reset
~ [start]

Hope it helps you.

arnaud commented 4 years ago

Hi. I'm assuming the latest answer was useful, and this ticket closed.

Do not hesitate to reach again if not,