Chatbots & it's testing techniques using Botium: Part 2

Chatbots & it's testing techniques using Botium: Part 2

Things to know before You Deep Dive into Botium

To understand the functioning of Botium and to have a smooth learning journey, I recommend you all to meet the following prerequisites:

1. Basic understanding of Javascript will help you in the learning journey(It doesn’t mean you must need developer skills to work with Botium )

2. Make sure you have a current version of Node.js installed on your workstation.

3. Choose the IDE to develop the scripts. ( I use VS Code, but it totally depends on each one’s choice)

4. Understanding the Botium Stack :

       We cannot inquire more into Botium without knowing the stack components. So I would explain one by one .

  a) Botium Core: The entirety of the parts in the Botium Stack is expanded on the top of Botium Core .Its also claimed as the brain and heart of botium

 b) Botium CLI : The Botium CLI is a command-line tool to actually use everything that Botium Core is capable to do. It is a command-line tool, which implies it doesn't furnish a graphical UI with buttons, pictures, and hyperlinks.

  c)Botium Bindings : ( This will be the candidate that I am going to explain more in my upcoming articles)

It is the technology bridge between Botium and test runners such as Jasmine, Mocha, Jest. So if you are into test automation and want to integrate automated chatbot testing into your CI/CD pipeline, Botium Bindings is yours!

 d) Botium Box: (Enterprise version ): Botium Box is the pretty face of Botium.A cutting edge, responsive, easy-as-hell web-based graphical user interface to configure, control, and monitor every aspect of Botium Core.

Botium Platform extends the open-source Botium Stack libraries with enterprise features while the Botium Stack libraries are open source and free.


Let's get familiarize with terms Convo, Utterances and botium.json file in Botium

 When learning a new programming language, it’s traditional for the first program to be the “Hello World” program. So I would also like to show an example of the “Hello World “ test case. The most basic test case in Botium consists of

      1) submitting an expression conceivably entered by a genuine user to the chatbot

      2) checking the reaction of the chatbot with the expected result

In Botium, the test cases are depicted by dialog flows, the chatbot should follow. For example "Greeting" situation, the BotiumScript(test cases) resembles the below:

#me
hello bot!

#bot

Hello,How can I help you ?

We can write above BotiumScript in different formats, as follows:

  • plain text file with Notepad or any other text editor(testcasename.convo.txt)
  • Excel file(testcasename.xlsx)
  • CSV file (testcasename.convo.csv)
  • Yaml file(testcasename.convo.yaml)  

      

Convos and Utterances

So, let’s elaborate on the “Hello, World!”-example from above. While some users will say “hello”, others may prefer “hi”:

#me
hello bot!

#bot

Hello,How can I help you ?

Another user may enter the conversation with “hey dude!

#me
hey dude
 

#bot
Hello, How can I help you ?

And there are plenty of other phrases we can think of. For this most simple use case, there are now at least three or more BotiumScripts to write. So let’s rewrite it.

We name this file hello.convo.txt:

TC01 – Greeting

#me
HELLO_UTT
 
#bot

Hello, How can I help you ?

 You may have noticed the additional lines toward the start of the BotiumScript.The first line contains a reference name for the test case to make it easier for you to locate the failing conversation within your test case library.

And we add another file hello_utt.utterances.txt:

HELLO_UTT

hello bot!
hi bot!
hey dude
good evening
hey are you here
anyone here?

The first BotiumScript is a convo file — it holds the structure of the conversation you expect the chatbot to follow.

The second BotiumScript is an utterances file — it holds several phrases for greeting someone, and you expect your chatbot to be able to recognize every single one of them as a nice greeting from the user.

Botium will take care that the convo and utterances files are combined to verify every response of your chatbot to every greeting phrase.

So now let’s assume that your chatbot uses several phrases for greeting the user back. In the morning it is:

#me
HELLO_UTT
 

#bot

Good morning,How can I help you this early ?

And in the evening it is:

#me
HELLO_UTT

#bot

Good evening,How can I help you at this late hour ?

Let’s extract the bot responses to another utterances file:

BOT_GREETING_UTT

Good evening
Good morning
Hello
Hi

And now comes the magic, we change the convo file to:

#me
HELLO_UTT

#bot

BOT_GREETING_UTT

Utterances files can be used to verify chatbot responses as well. To summarize:

An utterance referenced in a #me-section means: Botium send every single phrase to the chatbot and check the response

An utterance referenced in a #bot-section means: Chatbots may use any of these answers, and send the response back to Botium as all of them are fine.

botium.json file

In Botium , there are basically two configuration concepts.

 1) Capabilities: Which are similar to the "DesiredCapabilities" as used in Selenium and Appium: they describe in what context a Chatbot runs (or should run) and how Botium can connect to it.

2) Sources: This describes where Botium can pull the Chatbot container to run.

    Thus Botium reads configuration from botium.Json file. Botium has to somehow build up a communication channel with your chatbot. Depending upon the chatbot technologies, botium provides different connectors. Botium Connectors are based on Botium Core and are compatible with all Botium Components. Usually you have to talk to your development team to provide you the information in a configuration file “botium.json”.

Will see the botium.json file format for a chatbot developed with the Microsoft Bot Framework

{

 "botium": {

 "Capabilities": {

 "PROJECTNAME": "Directline3 Plugin Sample",

 "CONTAINERMODE": "directline3",

 "DIRECTLINE3_SECRET":"my-directline-secret",

 "DIRECTLINE3_WEBSOCKET": true,

 "DIRECTLINE3_POLLINGINTERVAL": 1000

    }

  }

}

The configuration items in Botium are called Capabilities. They are different for each supported chatbot technology. The one most important capability to tell Botium which technology to use to connect to your chatbot is CONTAINERMODE. In the example above, directline3 is given to instruct Botium to use the Microsoft Bot Framework technology called Directline, Version 3. Also there are several connector technologies supported, from which I will discuss the working of botium with Microsoft LUIS more in my upcoming articles.

 Really interested in quick start Botium scripting?

Will go through a glimpse of Botium by starting the command line of choice in the next article…..

Great one Arun dev Resourceful article and well explained.

Very good writeup Arun dev . Looking forward for more ..

For some one who never touched upon botium can have a far better understanding of the basics from this article. Looking forward. For more Arun dev

A very informative, but easy-to-understand article!

To view or add a comment, sign in

More articles by Arun Dev

Others also viewed

Explore content categories