Quick Intents
In order to deal with small talks, Oscova offers the option of adding quick intents directly from within an Oscova Dialog
or by loading Small Talk KB (Knowledge-Base) from XML files.
Note
In our lab test, Oscova successfully loaded more than 10,000 Quick intents in 2762 milliseconds and took about an additional memory of 18,756K. The stats however may change in different iterations of Syn.Bot framework.
Adding Quick Intents
Developers can add quick intents dynamically from within their code by adding expression and response values to a dialog's QuickIntents
collection.
Simple quick intent
class SmallTalkDialog : Dialog
{
public SmallTalkDialog()
{
IntentAlias = "SmallTalk";
QuickIntents.Add("How are you?","I am going great.");
QuickIntents.Add("Hi there!", "Well, hello there!");
//More quick intents...
}
}
Important
Because every intent in Oscova requires an Intent name identifier, it is mandatory to specify an IntentAlias
when adding quick intents. This alias is used to give an indexed intent name to all added quick intents.
Quick Intent - Custom Response
Developers can also generate responses or perform actions by providing a reference method for the delegate signature delegate (Context, Result)
.
QuickIntents.Add("I like @sys.music.genre", (context, result) =>
{
var genre = result.Entities.OfType(Sys.MusicGenre);
result.SendResponse($"I like {genre} music as well.");
});
Quick Intent - Random Response
From version 5.0 Oscova supports random responses. You can specify a list of responses and Oscova will randomly deliver a response from the list when the intent is matched.
//Random quick intents
QuickIntents.Add("thank you", new List<string> { "You're welcome", "My Pleasure", "Not a problem", "Glad it helped" });
Note
Quick intents within Dialog
classes can only have Template expressions. Example type expressions are invalid as you cannot specify an explicit entity type.
Creating a Quick Intents document via SIML
To create an OSCOVA Small Talk Document you must ensure that the root element of the document is <Oscova>
as shown below.
<Siml>
<!--Dialogs Go here-->
</Siml>
Creating a quick intent dialog
To add an Oscova dialog create a new <Dialog>
element and specify the name of the dialog and provide an IntentAlias
.
<Siml>
<Dialog Name="MyDialog" IntentAlias="SmallTalk.Greetings">
<!--Intents go here-->
</Dialog>
</Siml>
Sample quick intent SIML document
<Siml>
<Dialog Name="SmallTalkDialog" IntentAlias="SmallTalk.Greetings">
<Intent>
<Expression>How are you?</Expression>
<Response>I am doing great!</Response>
</Intent>
<Intent>
<Expression>Hi there</Expression>
<Response>Well, hello there!</Response>
</Intent>
</Dialog>
</Siml>
The IntentAlias
attribute defines a common intent name for all the intents within the Dialog. Therefore, in the example code above if any of the intent is matches the corresponding response is generated by an intent with name smalltalk.greetings
Tip
You can download and customize a variety of Small Talks KBs from Oscova Small Talk Base