Skills for SUSI
Susi is an open source personal assistant can do a lot of amazing things for you apart from just answering queries in the text. Susi supports many action type such as answer, table, pie chart, RSS, web search, map. Actions contain a list of objects each with type attribute, there can be more than one actions in the object list. For example curl http://api.susi.ai/susi/chat.json?timezoneOffset=-330&q=Who+are+you We get a json response similar to { "query": "Who are you", "answers": [{ "data": [], "metadata": {"count": 0}, "actions": [{ "type": "answer", "expression": "I was told that I am a Social Universal Super Intelligence. What do you think?" }] }], } The above query is an example of action type ‘answer’, for developing more skills on action type answer refer to the Fossasia blog : How to teach Susi skills. In this blog we will see how to teach a table skill to susi and how susi interprets the skill .So let’s add a skill to display football teams and its players using service Football-Data.org . For writing rules Open a new etherpad with a desired name <etherpad name> at http://dream.susi.ai/ Next let’s set some query for which we want Susi to answer. Example queries: tell me the teams in premier league | Premier league teams To get answer we define the following rule !console: { "url":"http://api.football-data.org/v1/competitions/398/teams", "path":"$.teams", "actions":[{ "type":"table", "columns":{"name":"Name","code":"Code","shortName":"Short Name","crestUrl":Logo}, "count": -1 }] } eol Expalanation: The JSON response for above URL look like this: { "_links": { "self": { "href": "http://api.football-data.org/v1/competitions/398/teams" }, "competition": { "href": "http://api.football-data.org/v1/competitions/398" } }, "count": 20, "teams": [{ "_links": { "self": { "href": "http://api.football-data.org/v1/teams/66" }, "fixtures": { "href": "http://api.football-data.org/v1/teams/66/fixtures" }, "players": { "href": "http://api.football-data.org/v1/teams/66/players" } }, "name": "Manchester United FC", "code": "MUFC", "shortName": "ManU", "squadMarketValue": null, "crestUrl": "http://upload.wikimedia.org/wikipedia/de/d/da/Manchester_United_FC.svg" }, { "_links": { "self": { "href": "http://api.football-data.org/v1/teams/65" }, "fixtures": { "href": "http://api.football-data.org/v1/teams/65/fixtures" }, "players": { "href": "http://api.football-data.org/v1/teams/65/players" } }, "name": "Manchester City FC", "code": "MCFC", "shortName": "ManCity", "squadMarketValue": null, "crestUrl": "https://upload.wikimedia.org/wikipedia/en/e/eb/Manchester_City_FC_badge.svg" }] } The attribute 'path' statuses object contains a list of objects for which we want to show the table. The table is defined with the action type "table" and a columns object which provides a mapping from the column value names to the descriptive names that will be rendered in the client's output. In our case, there are 4 columns Name of the team, Team Code, Short Name of the team, and the Team logo’s URL. The count attribute is used to denote how many rows to populate the table. If count = -1 , then it means as many as possible or displays all the results.It's easy, isn’t it? We have successfully created table skill for SUSI. Let’s try it out Go to http://chat.susi.ai/ and type: dream < your dream name>. And type your queries like “tell me the teams in premier league” in our case and see how SUSI presents you the results Next, want to create some more skills. Let’s teach SUSI to play a game Rock, Paper, Scissors, Lizard, Spock. SUSI can give random answers…
