One of the best feature provided in making a skill is the ease of using variables. From storing the favourite book of the user to the most recent movie he searched for to the mood he is in, variables play an indispensable part. If any problem is faced with the code part, the skill referred in this blog is coded in this file in susi_skill_data repository.
This link refers to the official docs of SUSI, which walk you through some basic examples of how to use variables in a SUSI skill. Great skills can be achieved using them like the skill below:
It’s easy to make such skills by using variables. Let’s check it out how this skill can be achieved.
To store value in a variable we use this syntax during the skill development
^value^>_variableName
First, let’s save the favourite dish of the user and then we will try to surprise him/her with a witty answer.
I love * dish ^$1$^>_userFavouriteDish
So, if the user types “I love biryani dish”, $1$ will be equal to biryani. Let’s save it to _userFavouriteDish variable.
Now if user asks “What should i eat” to SUSI, I bet SUSI will answer a well calculated answer!
What should i eat? I am sure you will love $_userFavouriteDish$!
Another example that can answer back the user efficiently:
How to cook biryani?
#Gives recipies and links to cook a dish * cook * !console:To cook $title$ , check out $href$ and make sure you have $ingredients$! ^$2$^>_recentSearch { "url":"http://www.recipepuppy.com/api/?q=$2$", "path":"$.results" } eol
In the above code, we saved the dish searched for at the end of the output.
If somehow user ends up asking “what is the most recent dish i searched for”. It’s skill will be:
what is the most recent dish I searched for? It was $_recentSearch$
Even if before asking this question, user asks “how to cook sushi”. The _recentSearch variable will be overridden with value “sushi” instead of “biryani”. Hence, SUSI won’t mistake answering “most recent dish” as “sushi”!
Now I think we are bit comfortable with use of variables in a skill. Let’s get back to our target skill i.e. remembering skill. We store the thing asked to remember in a variable having the same name as of that thing and the statement related to it as the value of that variable. Examples:
Remember that my keys are on the table. So the variable will be named “keys” and it’s value will be “on the table”.
Remember that my birthday is on 20th of December. So the variable will be named “birthday” and it’s value will be “on 20th of December”.
Remember that my meetings are at 8 pm with mentors and at 9:30 pm with Shruti. So the variable will be named “meetings” and it’s value will be “at 8 pm with mentors and at 9:30 pm with Shruti”.
Hence the skill:
Remember that my * is * | Remember that my * is * Okay, remembered!^$2$^>_$1$
When the user will ask for any of its thing, we will just show the value of the variable having the same name as of the thing asked. Examples:
#$_keys$ will be our answer Where are my keys? On the table #$_meetings$ will be our answer When are my meetings? at 8 pm with mentors and at 9:30 pm with Shruti
Hence the skill which answers the question is:
when are my * | where is my * | where are my * $_$1$$
So the skill as a whole will be:
Remember that my * is * | Remember that my * is * Okay, remembered!^$2$^>_$1$ when are my * | where is my * | where are my * $_$1$$