SUSI Server needs to provide an API which would return the private skill’s file content. The private skill is used for the botbuilder project. Since the skill is private, the fetching process is little different from that of the public skills. The client has to provide the user’s access_token and a parameter private to access the private skill instead of the public skill. This blog explains how the private skill is being fetched from the SUSI Server.
Understanding the API
The API used to fetch public skill is /cms/getSkill.json, with the following parameters:
These parameters helps to uniquely identify the skill.
The same API is used to fetch private skill too. But the parameters changes to:
The access token is used to authenticate the user, since the user should only be able to fetch their own private skill. The access token is also used to extract the user’s UUID which will be useful for locating the private skill.
Fetching the Private Skill from private skill repository
Now that we have all the necessary parameters, we can fetch the private skill from the susi_private_skill_data repository. The susi_private_skill_data folder has the following structure:
Thus to locate the skill, we will need the above parameters which we got from client and the user’s UUID. The following code checks if the client is requesting for private skill and changes the directory path accordingly.
- JSON Object in java: https://docs.oracle.com/javaee/7/api/javax/json/JsonObject.html
- Work with Files in java: https://docs.oracle.com/javase/7/docs/api/java/io/File.html