Skip to main content

Testing a slot filling script

tip
Testing a slot filling bot script is a step-by-step description of the interaction between a user and a bot with expected responses.

Let’s have a look at a slot filling testing example based on a simple script:

require: slotfilling/slotFilling.sc
module = sys.zb-common

theme: /

state: Start
q: $regex</start>
a: Let’s start!

state: Weather
intent!: /Weather
a: Weather in {{$parseTree._City}} for {{$parseTree._Date.value}}

state: CatchAll
event: noMatch
a: noMatch

Here, the /Weather intent reacts to the user asking for a weather forecast. Slots are filled as follows:

Filling in the slots

Here, @City is a custom entity where we specify all the cities available for a weather forecast.

Script behavior for various client requests:

  1. Weather for tomorrow in London: slots are filled, the bot will answer immediately.
  2. Weather for tomorrow: the City slot is not filled, additional questions will be asked. As soon as a correct answer is given, the control will be passed to the script and the bot will give a reply.
  3. Weather in London: the Date slot is not filled, additional questions will be asked. As soon as a correct answer is given, the control will be passed to the main function and the bot will give a reply.

Test for the script:

<test>
<test-case>
<q>/start</q>
<a>Let’s start!</a>
<q>Weather forecast</q>
<a>In which city?</a>
<q>In London</q>
<a>For which date?</a>
<q>For December 11, 2019</q>
<a>Weather in London for 2019-12-11T00:00:00</a>
</test-case>
</test>

In this test case, we have some of the slots not filled. So, the <q>Weather forecast</q> request is followed by the additional request script. When all the slots are filled, the script exits the slot filling mode.

When you compose slot filling tests, please consider various situations where, for example, one slot is already filled but the subsequent ones are still to be filled.