如何在 botium 中将变量与话语文件一起使用
How to use variables with an utterance file in botium
我有一个 botium/dialogflow 项目,我的开发人员使用 node 而不是 botiumbox 创建了该项目。我希望能够使用变量以多种方式调用多个社区。例如,我知道在自适应卡中使用变量应该是这样的:
Show me a neighborhood
#me
Show me a neighborhood in $neighborhood
#bot
In $neighborhood, there are [0-9]+ active listings.
我之前使用的是包含不同类型话语的话语文件,例如:
NEIGHBORHOOD_SNAPSHOTS_UTT
Show me a location in Lawrenceville
Show me a market snapshot in Lawrenceville
What are the market stats in Lawrenceville
Find market snapshot in Lawrenceville
我的自适应卡看起来像这样:
Show me a neighborhood
#me
NEIGHBORHOOD_SNAPSHOTS_UTT
#bot
In Lawrenceville, there are [0-9]+ active listings.
在 botium wiki 的某个地方我看到了类似的东西,所以我将它保存为一个名为 location.txt 的文件,与我的对话和话语文件位于同一文件夹中
|$neighborhood |
Case1 | Lawrenceville |
Case2 | Midway |
Case3 | Paintsville |
Case4 | River Point |
Case5 | The Fountains |
Case6 | Castlewood |
Case7 | Middlebury |
Case8 | Happy Valley |
Case9 | 20th / Breakwood |
Case10| Courtney Ct/Knight Ave |
现在我想把它们绑在一起,这样我就可以通过多种方式查询多个街区,比如
Show me a neighborhood
#me
NEIGHBORHOOD_SNAPSHOTS_UTT.utterances.txt
#bot
In $neighborhood, there are [0-9]+ active listings.
我将话语文件从 Lawrenceville 更改为:
Show me a location in $neighborhood
Show me a market snapshot in $neighborhood
What are the market stats in $neighborhood
Find market snapshot in $neighborhood
但我的项目似乎没有找到 location.txt 变量文件。我怎样才能让话语、变量文件和这些自适应卡片在我的项目中协同工作(不是 botium box)?
基本上,您尝试创建的测试用例没有问题,您做对了很多事情,但也有一些缺失。
脚本内存文件将被命名为 location.scriptingmemory.txt(参见 Botium Wiki)
话语文件的第一行是它从 convo 文件中引用的名称(你的一个例子是正确的,另一个不是)。
在 convo 文件中引用话语时,不要使用任何文件扩展名(一次正确,一次错误)。
#me
NEIGHBORHOOD_SNAPSHOTS_UTT
- 您必须在 Botium 中启用脚本内存,默认情况下它是禁用的 - 请参阅 Botium Wiki
- 最后,您希望 Botium 运行 多次使用更改的变量进行相同的转换,您也必须说明这一点(参见 Botium Wiki)
我准备了一个repl.it带demo
我有一个 botium/dialogflow 项目,我的开发人员使用 node 而不是 botiumbox 创建了该项目。我希望能够使用变量以多种方式调用多个社区。例如,我知道在自适应卡中使用变量应该是这样的:
Show me a neighborhood
#me
Show me a neighborhood in $neighborhood
#bot
In $neighborhood, there are [0-9]+ active listings.
我之前使用的是包含不同类型话语的话语文件,例如:
NEIGHBORHOOD_SNAPSHOTS_UTT
Show me a location in Lawrenceville
Show me a market snapshot in Lawrenceville
What are the market stats in Lawrenceville
Find market snapshot in Lawrenceville
我的自适应卡看起来像这样:
Show me a neighborhood
#me
NEIGHBORHOOD_SNAPSHOTS_UTT
#bot
In Lawrenceville, there are [0-9]+ active listings.
在 botium wiki 的某个地方我看到了类似的东西,所以我将它保存为一个名为 location.txt 的文件,与我的对话和话语文件位于同一文件夹中
|$neighborhood |
Case1 | Lawrenceville |
Case2 | Midway |
Case3 | Paintsville |
Case4 | River Point |
Case5 | The Fountains |
Case6 | Castlewood |
Case7 | Middlebury |
Case8 | Happy Valley |
Case9 | 20th / Breakwood |
Case10| Courtney Ct/Knight Ave |
现在我想把它们绑在一起,这样我就可以通过多种方式查询多个街区,比如
Show me a neighborhood
#me
NEIGHBORHOOD_SNAPSHOTS_UTT.utterances.txt
#bot
In $neighborhood, there are [0-9]+ active listings.
我将话语文件从 Lawrenceville 更改为:
Show me a location in $neighborhood
Show me a market snapshot in $neighborhood
What are the market stats in $neighborhood
Find market snapshot in $neighborhood
但我的项目似乎没有找到 location.txt 变量文件。我怎样才能让话语、变量文件和这些自适应卡片在我的项目中协同工作(不是 botium box)?
基本上,您尝试创建的测试用例没有问题,您做对了很多事情,但也有一些缺失。
脚本内存文件将被命名为 location.scriptingmemory.txt(参见 Botium Wiki)
话语文件的第一行是它从 convo 文件中引用的名称(你的一个例子是正确的,另一个不是)。
在 convo 文件中引用话语时,不要使用任何文件扩展名(一次正确,一次错误)。
#me
NEIGHBORHOOD_SNAPSHOTS_UTT
- 您必须在 Botium 中启用脚本内存,默认情况下它是禁用的 - 请参阅 Botium Wiki
- 最后,您希望 Botium 运行 多次使用更改的变量进行相同的转换,您也必须说明这一点(参见 Botium Wiki)
我准备了一个repl.it带demo