简体   繁体   English

Twilio 带翻译的 IVR 流程

[英]Twilio IVR flow with translations

I am trying to add multiple languages to my studio flow.我正在尝试将多种语言添加到我的工作室流程中。 1 - English, 2 - Spanish, 3 - French. 1 - 英语,2 - 西班牙语,3 - 法语。

When the user selects the language I am saving the selected lang in {{flow.variables.lang}} .当用户选择语言时,我将所选语言保存在{{flow.variables.lang}}中。 Based on the selected lang, I then load the respective translations.根据所选的语言,我然后加载相应的翻译。

I have multiple strings which use values set in the previous widget.我有多个字符串,它们使用在前一个小部件中设置的值。 I am not understanding how to set these values dynamically.我不明白如何动态设置这些值。

For Example:例如:

String: "Welcome to Studio flow, we found your information in our system with zip code {{widgets.User_Information.parsed.zipCode}} "字符串:“欢迎使用 Studio Flow,我们在我们的系统中找到了您的信息,代码为 zip {{widgets.User_Information.parsed.zipCode}}

In the translation file, I have this string set to key "User_Zip_Code".在翻译文件中,我将此字符串设置为关键字“User_Zip_Code”。

In the widget "Gather Input on call" I added {{widgets.Translation_Function.parsed.User_Zip_Code}} in the text to say field.在“Gather Input on call”小部件中,我在 text to say 字段中添加了{{widgets.Translation_Function.parsed.User_Zip_Code}} But when the voice reads it out, I expected Twilio would parse the and insert the dynamic value, but it just read it out as is.但是当语音读出时,我预计 Twilio 会解析并插入动态值,但它只是按原样读出。 Is there a way to dynamically insert these flow variables in the string dynamically?有没有办法动态地将这些流变量动态地插入到字符串中?

One way I could think of is to call a function and have that function return the string after replacing the values, but for some reason, there are a lot of gaps that I am seeing when the flow moves from one function to another, so I am trying to avoid function calls.我能想到的一种方法是调用 function 并让 function 在替换值后返回字符串,但出于某种原因,当流程从一个 function 移动到另一个时,我看到了很多差距,所以我我试图避免拨打 function 电话。

EDIT:编辑:

Adding the data shown in the Widget & Flow Properties添加 Widget & Flow Properties 中显示的数据

 "User_Information": {
      "status_code": 200,
      "content_type": "application/json",
      "parsed": {
        "zipCode": 201010
      },
}
    "Translation_Function": {
      "status_code": 200,
      "content_type": "application/json",
      "parsed": {
          "User_Zip_Code": "Welcome to Studio flow, we found your information in our system with zip code {{widgets.User_Information.parsed.zipCode}}. Press pound to continue.”
    },
}

Thanks in advance提前致谢

It should work as you explained.它应该像你解释的那样工作。 Are you sure the reference in the liquid syntax is indeed correct, for example: {{widgets.User_Information.parsed.zipCode}} ?您确定 liquid 语法中的引用确实正确,例如: {{widgets.User_Information.parsed.zipCode}}吗?

Try looking at the Studio Flow Execution Logs (under Logs) to see the path you must refer to in the liquid syntax is correct/尝试查看 Studio Flow Execution Logs(在 Logs 下)以查看您必须在 liquid syntax 中引用的路径是否正确/

在此处输入图像描述

Update:更新:

It appears you are nesting Liquid Syntax expressions.看来您正在嵌套 Liquid Syntax 表达式。 What I mean by that is your Gather Input on Call Widget is referencing parsed JSON from an earlier Widget and that JSON has a liquid syntax expression in it.我的意思是,您的 Gather Input on Call Widget 引用了早期 Widget 中已解析的 JSON,而 JSON 中有一个流畅的语法表达式。

Example JSON:示例 JSON:

"FT_Fee_Information": "We found your account in our XX payment system. As a reminder, payments processed through this system are subject to a $x.xx convenience fee. Payments without a fee can be made through the My Account portal on our website at example.com. If you would like to use the stored payment information to make a payment on account ending in {{widgets.Validate_Number.parsed.accountNumber}}. Please enter the 5 digit zip code associated with this account. If you would like to pay on a different account press the pound key. "FT_Fee_Information": "我们在我们的 XX 支付系统中找到了您的账户。提醒一下,通过该系统处理的支付需要支付 $x.xx 便利费。可以通过我们网站上的我的账户门户进行免费支付在 example.com。如果您想使用存储的付款信息对以 {{widgets.Validate_Number.parsed.accountNumber}} 结尾的帐户进行付款。请输入与此帐户关联的 5 位代码 zip。如果您愿意想在不同的帐户上付款,请按井号键。

I am pretty sure that is the reason for your issue, you can't nest these liquid syntax expression.我很确定这就是您遇到问题的原因,您不能嵌套这些流式语法表达式。 Instead, can you pass in the Studio data to the Function calling the JSON so that Function can pre-populate this information (static data) into JSON (instead of using a liquid expression) before returning the JSON blob to Studio?相反,您能否将 Studio 数据传递给调用 JSON 的 Function,以便 Function 可以在将 JSON blob 返回给 Studio 之前将此信息(静态数据)预填充到 JSON(而不是使用液体表达式)?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM