Prompt
In Oscova prompts can be added to intents for missing entity types. The user will receive the prompt message if an intent is invoked and the specified prompt entity type is missing.
Adding a Prompt
Suppose we have an intent that play music by genre. We could add a prompt message that is received by the user if the user message doesn't contain an music genre.
[Expression("play {rock} music")]
[Entity(Sys.MusicGenre)]
[Prompt(Sys.MusicGenre, "Please specify a genre.")]
public void OpenApp(Context context, Result result)
{
//Do Something.
}
If the user just says Play Music the bot will respond Please specify a genre.
Prompts for multiple entity types are supported. Until all the specified entity types are found the user will keep receiving respective prompt message.
Prompt Context
Internally Oscova handles prompts via context manipulation. However, developers can explicitly specify a context for a prompt in case a contextual fallback is required.
The following code shows how a context can be explicitly specified for a prompt.
[Expression("{login} @emp-code")]
[Expression("{log-in} @emp-code")]
[Entity("login")]
[Prompt("@emp-code","Please specify emp code.", Context = "in-login")]
public void LoginEmp(Context context, Result result)
{
//Do something here.
}
[FallBack(Context = "in-login")]
public void LoginFallback(Context context, Result result)
{
context.Remove("in-login");
//Do something here.
}