2016-12-12 14 views
2

저는 봇 프레임 워크를 처음 사용하고 노드 SDK를 사용하여 스카이프 채팅 봇에서 작업하고 있습니다.Skype chat bot framework - node.js

트리 데이터의 ID와 이름을 제공하는 JSON 트리 배열이 있습니다. 트리에서 타이틀을 얻기위한

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}] 
     } 
    ] 
}); 

코드입니다.

var node1 = treeName.first(function (node) { 
    return node.model.id === 1; 
}); 

배열

나는 ID가 잘 작동하지만 하나 개의 배열에 제목을 얻으려면 나는이 오류 얻을 얻으려고
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); 

:

/node_modules/promise/lib/done.js:10 
     throw err; 
    ^

TypeError: choice.trim is not a function 

답변

1

'선택'변수를 어디에도 정의하지 않은 것처럼 보입니다.

treeName.title 

또는

treename.children[X].title 

첫번째 것이며,이 경우, 복귀 '메뉴'에서, 두 번째는 "등 company_data"또는 "애드혹 데이터 테스트"를 반환하는 반면

배열이나 개체에 .trim()을 사용할 수 없습니다.

편집 : 내가 찾은 것을보세요 ... https://github.com/Microsoft/BotBuilder/issues/2004