将变量从“twilio:gather_start”传递到事件KRL 中的命令

发布于 2024-10-06 16:53:17 字数 449 浏览 4 评论 0原文

我正在编辑 KRL/Twilio 应用程序,并且有一个收集用户输入的事件。是否可以将变量传递到 "gather_start" 触发的事件中?以下是我到目前为止尝试过的不起作用的方法(在本例中,它试图将 var“color”传递为“red”):

twilio:gather_start("choice") with action="choice?color=red" and numDigits = "1" and timeout = "5" and color = "red" and parameters = {"color":"red"};

似乎持久变量可能是最好的(设置类似“ent:color”的内容)到“红色”),但听起来应用程序持久变量还不可用? TIA。

I'm editing a KRL/Twilio app, and I have an event that gathers input from the user. Is it possible to pass a variable into the the event that "gather_start" fires? Here are the ways I've tried so far that don't work (in this case it's trying to pass the var "color" as "red"):

twilio:gather_start("choice") with action="choice?color=red" and numDigits = "1" and timeout = "5" and color = "red" and parameters = {"color":"red"};

Seems like persistent vars might be best (set something like "ent:color" to "red"), but it sounds like application persistent vars aren't available yet? TIA.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

再可℃爱ぅ一点好了 2024-10-13 16:53:17

正确的方法是持久变量。应用程序变量是一种选择,但您可能想要的是实体变量。 Kynetx Webhooks 与 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();
  }

The right way to do this is persistent variables. App variables are one option, but what you probably want is entity variables. Kynetx Webhooks work with Twilio's cookie jar, resulting in a session that maintains entity variables in kynetx apps.

Each phone call gets a session of it's own, so you don't need to worry about multiple simultaneous calls stepping on each other.

App persistent variables (use app:myvar instead of ent:myvar) will work, but are global to the application, so they should only be used when the variables are scoped to the app.

Here's a few rules that demonstrate this:

 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();
  }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文