SUSI Server needs to provide an API which would return the private skill’s metadata. This metadata will include the chatbot’s design and configuration settings. The skill’s meta data is being stored in the chatbot.json file in the server. This API will be called from the websites where the chatbot has been deployed. The skill’s metadata will be used for customizing the design of the chatbot. This blog explains how the API for fetching a private skill bot’s metadata is made.
Understanding the API
The API used to fetch public skill’s metadata is /cms/getSkillMetadata.json, with the following parameters:
These parameters help to uniquely identify the skill.
The same API is used to fetch private skill’s metadata too. But the parameters changes to:
The userid also helps to secure the identity of the user. Unlike email id, the user can be easily identified using the userid. Also it prevents from accessing other user’s chatbots without knowing their userid.
Understanding the data stored
In the chatbot.json file, the skill’s metadata are stored in the following format:
Thus, each entry is stored as a key-value pair. This makes the retrieval of record very efficient.
Making API to fetch private skill bot’s settings
In GetSkillMetadataService.java file, we detect if the client is sending the “userid” parameter or not. For fetching public skill’s metadata, the client will send the “model” parameter and for fetching private skill bot’ settings, the client will send the “userid” parameter. To fetch the private skill bot’s settings, we need to extract it from the chatbot.json file. We fetch the entire object for the particular skill and return it:
This gives the following output:
- 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