[英]Skype chat bot framework - node.js
I'm new to the bot framework and working on the skype chat bot by using node SDK.我是机器人框架的新手,正在使用 node SDK 开发 Skype 聊天机器人。
I have JSON tree array which provide me the id and names for tree data.我有 JSON 树数组,它为我提供树数据的 id 和名称。
treeName = tree.parse({
"id": 1,
"title": "menu",
"children": [
{
"id": 11,
"title": "company _ data",
"children": [{"id": 111}]
},
{
"id": 12,
"title": "adhoc data test ",
"children": [{"id": 121}, {"id": 122}]
},
{
"id": 13,
"title": "quit",
"children": [{"id": 131}, {"id": 132}]
}
]
});
Code for get the title from tree.从树中获取标题的代码。
var node1 = treeName.first(function (node) {
return node.model.id === 1;
});
Array大批
var firstChild = [];
for (var i = 0; i < node1.model.children.length; i++) {
firstChild.push(node1.model.children[i].title);
}
builder.Prompts.choice(session, "What scenario would you like to run? ",firstChild );
When I'm trying to get the id it will work well but if I want to get title in one array then I get this error:当我尝试获取 id 时,它会运行良好,但如果我想在一个数组中获取标题,则会出现此错误:
/node_modules/promise/lib/done.js:10
throw err;
^
TypeError: choice.trim is not a function
You don't appear to have defined the variable 'choice' anywhere.您似乎没有在任何地方定义变量“选择”。
treeName.title
or或者
treename.children[X].title
The first one would, in this case, return 'menu', whereas the second one returns "company_data", or "adhoc data test", etc.在这种情况下,第一个将返回“菜单”,而第二个将返回“company_data”或“adhoc data test”等。
You cannot use .trim() on arrays or objects.不能在数组或对象上使用 .trim() 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.