在 IBM Watson Assistant 中将自由文本存储为变量

Store free text as variable in IBM Watson Assistant

我想知道 IBM Watson 助手是否有办法将用户的自由文本或直接输入存储为变量。我知道你可以用下面的代码用数字来完成:

"context" : {
    "number_extract" : "<? input.text.extract('[\d]+',0) ?>"
}

但这只适用于数字。当您想存储自由文本时,您会怎么做?作为变量的名称?相同的代码不适用于任何其他文本但数字所以我假设必须有一个代码适用于文本或自由文本。我将衷心感谢您的帮助。谢谢。

可以使用 input.text 简单地访问输入。 See this part of the documentation.

在您的示例中,对输入字符串应用了一个额外的 extract 函数。 extract function is a regex string (regular expression search string). In your sample, it searches for the first number. You can also search for other components, our transform the string. See the docs for other functions you can apply.

的参数

我也收藏了samples for working with context variables in this GitHub repository