Do KRL rules stop running when a Twilio call ends? -


if create toddler amusement line (see http://blog.tropo.com/2010/11/22/something-fun-and-quick-to-make-the-toddler-amusement-line/) using twilio , kynetx need set stop condition in ruleset or evaluations end when caller hangs up?

// warning! not use ruleset! rule callstart {   select when twilio callstart   { raise explicit event loves_me } }  rule loves_me {   select when explicit loves_me   twilio:say("she loves me.")   { raise explicit event loves_me_not } }  rule loves_me_not {   select when explicit loves_me_not   twilio:say("she loves me not.")   { raise explicit event loves_me } } 

my guess: call starts ruleset running. caller rings off. small part of kns cries.

actually, code here never return twilio @ all.

twilio raises events @ call start , during call when instructed. happens twilio:gather_start() , twilio:redirect() among others.

when raise explicit event, matching rules select , fire before response sent. because of loop here, response never sent. way test call webhook give twilio browser, , @ response.

a better way make happen give twilio piece of instructions, , have raise event when finished. rewrite code above:

rule callstart {   select when twilio callstart   { raise explicit event loves_me } }  rule loves_me {   select when explicit loves_me or twilio loves_me   twilio:say("she loves me.");   { raise explicit event loves_me_not } }  rule loves_me_not {   select when explicit loves_me_not   {     twilio:say("she loves me not.");     twilio:redirect("loves_me");   { } 

note replaced 1 of raise explicit event statements. replace of them in similar manner, result in more events raised kynetx necessary. balance , can adjusted necessary.

(also note or in select statement of loves_me rule, , addition of {} allow 2 actions in single rule. , ;s after actions.)

this pattern of using redirect useful when wish repeat menu options, if user not choose option before timeout. shown in phone menu tutorial in kynetx docs.


Comments