Whenever a user in using an API, for example chat.susi.ai, the user send a query to the API. This query is then sent by the API as a request to the susi server. The server then process the request and sends the answer to the query in form of json data as a response to the request. This request is then used by the API to display the answer after applying stylings to the json data.
The json data looks like this(below is the response to hi susi by the server):
Whenever a request to server is made the server process the data and looks for the skills file for the corresponding file. For our above example(hi susi) the required skill file is susi_server/conf/susi/en_0700_ai_play.json
The format of file names for the skills is <language>_<index>_<title_of_skill>.json
In the rules attribute we can see a number of phrases attributes are there, each corresponding to a specific class of query like hello, sorry, help etc. In our example we have the query “hi susi” which corresponds to the hello type phrase. From this code block:
we see an array of length 3 with expressions with ‘hello’, ‘hi’, or ‘hey’ keywords. SUSI assumes all 3 types of queries same and performs same actions for these three types of expressions which are directed below in the actions attribute. ‘actions’ is an array with three columns:
- type : this defines the type of response(here answer).
- select : This defines the type of action like random or the value of a specific index of phrases[i] array. Here the value is random, which means that a random value from the phrases array will be the answer for this query with both “Hi! I’m SUSI” and “Hello!” have equal probability to appear as the answer.
- phrases : It’s an array which holds all the possible answers for a query.
The server process and create the response json data file with other attributes like the time of creation of an answer,language, the client Id, answer time, session information, link to the skills file and skill used etc. and sends the response to the client.