Transparent logic via preprocessor
Preprocessor allows you to declare digression, which should work transparently from the point of view of the script. If during the processing of an event a transition is made to the preprocessor, then after returning to the node, processing of the event will continue from the same place where it was interrupted.
Example
The preprocessor can be used for user phrases counting during the whole dialogue.
main.dsl
1 context 2 { 3 output phraseCount: number = 0; 4 } 5 start node root 6 { 7 do 8 { 9 #connectSafe("myEndpoint"); 10 goto askCountinue; 11 } 12 transitions 13 { 14 askCountinue: goto askCountinue; 15 } 16 } 17 node askCountinue 18 { 19 do 20 { 21 #say("Do you want to talk?"); 22 wait *; 23 } 24 transitions 25 { 26 listen: goto listen on #messageHasSentiment("positive"); 27 @exit: goto @exit on #messageHasSentiment("negative"); 28 } 29 } 30 node listen 31 { 32 do 33 { 34 #say("Ok. I'm listening."); 35 wait *; 36 } 37 transitions 38 { 39 askCountinue: goto askCountinue on true; 40 } 41 } 42 node @exit 43 { 44 do 45 { 46 #say("Goodbye then."); 47 set $phraseCount = digression.phraseCounter.count; 48 exit; 49 } 50 transitions 51 { 52 } 53 } 54 // Each time interlocutor say a phrase, we count it 55 // then return to the waiter and continue to handle a phrase. 56 preprocessor digression phraseCounter 57 { 58 conditions 59 { 60 on true; 61 } 62 63 var count: number = 0; 64 65 do 66 { 67 set digression.phraseCounter.count += 1; 68 return; 69 } 70 }
Found a mistake? Let us know.