Skip to content

Core Intent Library

Jordi Cabot edited this page Nov 15, 2021 · 4 revisions

Many bots share some common intents (to say hello, to thank you, to ask for help, to say no,...) that you don't want to repeat every single time. To save you some time, Xatkit includes a Core Intent Library, integrated in the runtime, which you can directly reuse in your new bot project.

A couple of examples of predefined intents in the library

    public static IntentDefinition No = intent("No")
            .trainingSentence("No")
            .trainingSentence("no")
            .trainingSentence("nope")
            .trainingSentence("negative")
            .getIntentDefinition();


    public static IntentDefinition Help = intent("Help")
            .trainingSentence("Help")
            .trainingSentence("help")
            .trainingSentence("Assist")
            .trainingSentence("I need support")
            .trainingSentence("I need some help")
            .trainingSentence("I need some assistance")
            .getIntentDefinition();

Using the Core Intent Library

To use any of these intents in your bot you just need to import the library.

import com.xatkit.library.core.CoreLibrary;

Once imported, feel free to add the intents in any state transition. For instance, in this SimpleQA bot you'll find several examples where Core Library intents are used throughout the bot, as for the Greetings intent in this case:

        awaitingInput
                .next()
                .when(intentIs(CoreLibrary.Greetings)).moveTo(handleGreetings)
                .when(intentIs(xatkitInfo)).moveTo(giveInfo)
                .when(intentIs(wantBot)).moveTo(askBotSize);

Note that we prefix the core library intents with CoreLibrary.

i18n version of the Core Intent Library

If you need to develop bots in several languages, we have also released an internationalized version of the library. See this repository for more details

Create your own Intent Library

Same as we have created this core library, you can extend or create your own library optimized for the typical intents in your domain.

Clone this wiki locally