これを行う正しい方法は、永続変数です。アプリ変数は 1 つのオプションですが、おそらく必要なのはエンティティ変数です。Kynetx Webhook は Twilio の Cookie jar と連携して、kynetx アプリでエンティティ変数を維持するセッションを実現します。
各通話は独自のセッションを取得するため、複数の同時通話が互いに干渉することを心配する必要はありません。
アプリの永続変数 (app:myvar
の代わりに使用ent:myvar
) は機能しますが、アプリケーションに対してグローバルであるため、変数のスコープがアプリに限定されている場合にのみ使用する必要があります。
これを示すいくつかのルールを次に示します。
rule firstquestion {
select when twilio firstquestion
{
twilio:gather_start("firstanswer");
twilio:say("Question One");
twilio:gather_stop();
}
}
rule firstanswer {
select when twilio firstanswer
pre {
firstchoice = event:param("Digits");
}
{
twilio:gather_start("secondanswer");
twilio:say("Question Two");
twilio:gather_stop();
}
fired {
set ent:firstchoice firstchoice;
}
}
rule secondanswer {
select when twilio secondanswer
pre {
firstchoice = ent:firstchoice;
secondchoice = event:param("Digits");
}
noop();
}