2

I'm new to the bot framework and working on the skype chat bot by using node SDK.

I have JSON tree array which provide me the id and names for tree data.

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:

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

TypeError: choice.trim is not a function

1 Answer 1

1

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.

You cannot use .trim() on arrays or objects.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.