Twilio Studio 说/收集提示

问题描述

我们正在使用 Twilio Studio 来管理我们的 IVR 流,并且在识别特定数字时遇到了问题。

示例:其中包含 22 的验证码被 Twilio 识别为“tutu”

除了更改“识别语言”等设置外,我想让 Twilio 比其他输入更能识别数字。 “语音识别提示”有一个选项,它是一个逗号分隔的值列表——但你应该在那里放什么?文档只讨论了一个逗号分隔的列表,没有别的!

感谢收到任何帮助。

提前致谢

解决方法

您可以查看在提示部分输入 $OOV_CLASS_DIGIT_SEQUENCE 是否对捕获的 SpeechResult 有任何影响。

另一种选择是通过将 tutu 转换为 22 的标准化 Twilio 函数来运行结果。

我建议在捕获数字时使用 DTMF,以避免这种情况。

// converts number words to integers (e.g. "one two three" => 123)

function convertStringToInteger( str ) {
    let resultValue = "";
    let arrInput = [];
    let valuesToConvert = {
        "one": "1","two": "2","to": "2","three": "3","four": "4","five": "5","six": "6","seven": "7","eight": "8","nine": "9","zero": "0"
    };

    str = str.replace(/[.,-]/g," ");  // sanitize string for punctuation

    arrInput = str.split(" ");      // split input into an array

    // iterate through array and convert values
    arrInput.forEach( thisValue => {
      if( ! isNaN(parseInt(thisValue)) ) {  // value is already an integer
        resultValue += `${parseInt(thisValue)}`;

      } else {  // non-integer
        if( valuesToConvert[thisValue] !== undefined) {
          resultValue +=  valuesToConvert[thisValue];
        } else {
          // we don't know how to interpret this number..
          return false;
        }
      }
    });

    console.log('value converted!',str,' ====> ',resultValue);
    return resultValue;
}