Dialogs and Domains
A Dialog in OSCOVA is used to group together a collection of related intents, actions and quick replies. Creating a dialog is the first and foremost concept a developer would learn during their Bot development in OSCOVA.
Creating a Dialog
Creation of a Dialog is pretty straight forward in Oscova. To create an Oscova Dialog
create a class that is derived from the Dialog
class.
The code below shows an example dialog that would contain intents that help in interacting with apps.
Note
By convention dialog class names should end with the word Dialog
.
Once a dialog and its children intents or actions have been declared, the dialog can be added to Oscova as shown below:
var bot = new OscovaBot();
bot.Dialogs.Add(new AppDialog());
Domains
In Oscova dialog system domains provides scopes to dialogs that will be available to users that are explicitly allowed to access to dialogs belonging to those domains.
In the example code below the 2 dialogs TechSupportDepartmentDialog
and DevOpsDepartmentDialog
are decorated with a DialogAttribute
that specifies the domains to which each of the dialogs belong to. Also being in different domains the intents in the dialogs are using the same Trait
for the LoginIntent()
.
[Dialog(Domain = "tech-support")]
public class TechSupportDepartmentDialog : Dialog
{
[Trait(Type = "#login")]
public void LoginIntent(Context context, Result result)
{
//Do something
}
}
[Dialog(Domain = "dev-ops")]
public class DevOpsDepartmentDialog : Dialog
{
[Trait(Type = "#login")]
public void LoginIntent(Context context, Result result)
{
//Do something
}
}
Once dialogs have been provided with a Domain scope the programmer must develop a condition based on which each created BotUser gets their respective domains.
var bot = new OscovaBot();
bot.Dialogs.Add(new TechSupportDepartmentDialog());
bot.Dialogs.Add(new DevOpsDepartmentDialog());
bot.Trainser.StartTraining();
var techUser = bot.CreateUser();
techUser.Domains.Add("tech-support");
var devUser = bot.CreateUser();
devUser.Domains.Add("dev-ops");
In the code above when the techUser
says I want to login the LoginIntent
within TechSupportDepartmentDialog
will be invoked. Likewise, when the devUser
says I want to login the LoginIntent
within the DevOpsDepartmentDialog
will be invoked.