Create and configure analytics applications

Combine /config/apps, /appedit, and /config/folders requests to create an application, upload its configuration, and associate it with a folder.

The following sample JSON defines an application named New AppEdit Test.

Figure 1. Sample JSON that defines an Application
{
    "Technologies": {
        "Technologies-RD": {
            "New AppEdit Test": {
                "created": "2017-10-10",
                "defaultscoretype": "Hit/Miss",
                "enabled": "on",
                "folders": [
                    "AutoTests"
                ],
                "template": "custom"
            }
        }
    }
}

When programmatically creating an application, populating it, and binding it to a folder, you must create the application before you can do either of the other two tasks. The next sample shows the JSON that associates a folder with the application that was defined previously.

Figure 2. Sample JSON that Associates an Application with a Folder
{
    "Technologies": {
        "Technologies-RD": {
            "AutoTests": {
                "apps": [
                    "New AppEdit Test"
                ],
                "custom_meta": [],
                "modelchan0": "eng1:callcenter",
                "modelchan1": "spa1:callcenter",
                "nspeakers": 2,
                "servers": [
                    "asrsrvr1",
                    "asrsrvr8"
                ]
            }
        }
    }
}

The next sample shows an abbreviated version of the JSON configuration of an application.

Figure 3. Sample JSON for an Application
{
    "Sample Top Level Category": {
        "phrases": {
            "+": {
                "all": [
                    "phrase usually found in all calls of this category"
                ]
            },
            "-": {
                "all": [
                    "phrase that shouldn't occur in calls of this category"
                ]
            }
        },
        "subcategories": {
            "Sample 2nd Level Category": {
              ...
            },
            "Sample 2nd Level Leaf Category": {
            ...
            }
        }
    },
    "Sample Top Level Leaf Category": {
        "phrases": {
           ...
        },
        "subcategories": {}
    }
}

Once you have JSON that provides information about these three aspects of an application, you can create the application, bind it to a folder, and define its configuration with three cURL calls like the following:

  1. Calls the /config/apps endpoint to create the application, using the contents of the file app-definition.json .

    curl -s -X POST -H "Content-Type:application/json" "http://example.company.com:3000/config/apps?token=$token" --data @app-definition.json
  2. Calls the /config/folders endpoint to associate the new application with a specified folder, using the contents of the file app-folder-binding.json .

    curl -s -X POST -H "Content-Type:application/json" http:///example.company.com:3000/config/folders?token=$token" --data @app-folder-binding.json
  3. Calls the /appedit endpoint to upload the configuration of the application, using the contents of the file app-configuration-sample.json .

    curl -s -X POST -H "Content-Type:application/json" "http:///example.company.com:3000/appedit/Technologies/Technologies-RD/AppEdit%20Test?token=$token" --data @app-configuration-sample.json

While cURL provides a quick way to use and test REST APIs, and shell scripts are a quick and convenient way of automating many tasks, it is typically faster in the long run to call APIs from applications. The next topic discusses how to use the /appedit API from within applications that are written in the Python programming language.