This repository contains utility classes to do advanced testing on Xatkit chatbots.
-
You need to have Xatkit installed locally to use this project.
-
Install this project in your local maven repository:
git clone https://github.com/xatkit-bot-platform/labs-bot-testing-tools cd labs-bot-testing-tools mvn clean install
-
Add the dependency to your bot project:
<dependency> <groupId>com.xatkit</groupId> <artifactId>labs-bot-testing-tools</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency>
This test is used to check if the detected intent for a given utterance is the expected one (i.e. to test if a chatbot detects the correct intents). This code snippet can be used as an example:
public void intentsTest() {
testIntentMatching(
xatkitBot,
"myFile.csv",
state);
}
-
xatkitBot
must be a validcom.xatkit.core.XatkitBot
-
state
must be a validcom.xatkit.execution.State
, containing a set of intents that can be recignized through it (alternatively, instead of passing a state as a parameter, you can pass a list ofcom.xatkit.intent.IntentDefinition
directly) -
"myFile.csv
must be a csv file (located in thesrc/test/resources/
folder of your project) containing a table with this structure:
utterance | expected_intent | detected_intent | expected_parameters | detected_parameters |
---|---|---|---|---|
Hello | Greetings | |||
How are you? | HowAreYou | |||
My name is John and I live in Barcelona | Presentation | name = John; city = Barcelona |
Fill the expected_parameters
column if there is any parameter to be matched, so you can later compare them with
detected_parameters
After running this code, a file myFileResult.csv
will be created in the src/test/resources/
folder of your project,
filling the missing values of the detected_intent
column. If the detected intents match with the expected intents,
then your bot does what you want!
📚 Note that the intent detection will depend primarily on the intent recognition provider you use within your bot (e.g. Dialogflow or NLP.js)