Script setup
This article is part of a tutorial about creating an outbound call campaign using CAILA.
- Telephony setup
- Script setup (you are here)
- Campaign launch
- Analytics
- Additional features
- Testing
During this stage we will set up the bot script. We will utilize various $dialer
methods in the bot script extensions for telephony management, and we will be using CAILA for natural language understanding.
Configuration file
Go to the Editor and create a standard chatbot.yaml
configuration file for CAILA projects:
name: call-campaign
entryPoint: main.sc
botEngine: v2
language: en
nlp:
intentNoMatchThresholds:
phrases: 0.2
patterns: 0.2
The main script
Create the src/main.sc
file and put the main script mechanics into the theme
tag:
theme: /
state: Start
q!: $regex</start>
script:
$jsapi.startSession();
$session.userName = $dialer.getPayload().name || "stranger";
$dialer.setCallResult("Greeting");
a: Hello, {{$session.userName}}!
a: Due to the COVID-19 pandemic, the world government is concerned for your safety.
go!: /Symptoms
state: Symptoms
a: Have you recently found yourself with a fever, a dry cough, or a rapid tiredness?
state: Positive
intent: /Agree
intent: /Sick
a: Then do not put yourself in danger! Seek medical attention immediately!
script:
$dialer.reportData("Case", "Positive");
$dialer.setCallResult("Known case");
go!: /Goodbye
state: Negative
intent: /Disagree
intent: /Healthy
a: Good to hear everything is fine! Still, do not forget to wash your hands and wear face masks.
script:
$dialer.reportData("Case", "Negative");
$dialer.setCallResult("Known case");
go!: /Goodbye
state: Unrecognized
event!: noMatch
a: So you say: {{$parseTree.text}}. Remember about proper hygiene and wearing face masks.
script:
$dialer.reportData("Case", $parseTree.text);
$dialer.setCallResult("Known case");
go!: /Goodbye
state: Goodbye
event!: hangup
a: Goodbye and stay safe!
script:
$dialer.hangUp();
state: NoInput || noContext = true
event!: speechNotRecognized
script:
$session.noInputCounter = $session.noInputCounter || 0;
$session.noInputCounter++;
if: $session.noInputCounter >= 3
a: I’m sorry, there’s something wrong with the connection.
script:
$dialer.setCallResult("Bad connection");
go!: /Goodbye
else:
a: I didn’t catch that. Could you repeat, please?
Also create the test/test.xml
file, but leave it empty for now:
<test>
<test-case/>
</test>
Dialog start
When the bot reaches out to the client, it receives a /start
command, which can be processed with a pattern for regular expressions. The handler for this activator does the following:
- Marks the session as new and cleans previously stored session data.
- Extracts the client name from the phone number list and stores it in the session data.
- Sets the appropriate call result.
If no client name is provided, a neutral form of address is used instead.
state: Start
q!: $regex</start>
script:
$jsapi.startSession();
$session.userName = $dialer.getPayload().name || "stranger";
$dialer.setCallResult("Greeting");
a: Hello, {{$session.userName}}!
a: Due to the COVID-19 pandemic, the world government is concerned for your safety.
go!: /Symptoms
Reporting the client response
The states nested into the Symptoms
parent state handle different replies to the question about the client’s well-being, whether it be positive, negative, or unrecognized. In each case, the bot records the reply to the campaign report under the Case
column. Unrecognized responses are recorded as is.
state: Symptoms
a: Have you recently found yourself with a fever, a dry cough, or a rapid tiredness?
state: Positive
intent: /Agree
intent: /Sick
a: Then do not put yourself in danger! Seek medical attention immediately!
script:
$dialer.reportData("Case", "Positive");
$dialer.setCallResult("Known case");
go!: /Goodbye
state: Negative
intent: /Disagree
intent: /Healthy
a: Good to hear everything is fine! Still, do not forget to wash your hands and wear face masks.
script:
$dialer.reportData("Case", "Negative");
$dialer.setCallResult("Known case");
go!: /Goodbye
state: Unrecognized
event!: noMatch
a: So you say: {{$parseTree.text}}. Remember about proper hygiene and wearing face masks.
script:
$dialer.reportData("Case", $parseTree.text);
$dialer.setCallResult("Known case");
go!: /Goodbye
$dialer.reportData
Dialog end
During the last step, the bot says goodbye and ends the call.
state: Goodbye
event!: hangup
a: Goodbye and stay safe!
script:
$dialer.hangUp();
Unrecognized speech handling
The NoInput
technical state handles situations when no response from the client can be recognized. If the number of transitions to this state becomes greater than the threshold, the bot ends the call.
state: NoInput || noContext = true
event!: speechNotRecognized
script:
$session.noInputCounter = $session.noInputCounter || 0;
$session.noInputCounter++;
if: $session.noInputCounter >= 3
a: I’m sorry, there’s something wrong with the connection.
script:
$dialer.setCallResult("Bad connection");
go!: /Goodbye
else:
a: I didn’t catch that. Could you repeat, please?
speechNotRecognized
event handler and impose a limit on unrecognized requests per session, so that ineffective calls finish quickly without spending excessive call minutes.Intent setup
Go to CAILA > Intents and create the intents used in the script: /Agree
, /Disagree
, /Healthy
, and /Sick
. Fill them with training phrases conveying the appropriate meanings:
Agree | yes | yeah | I have | yep |
Disagree | no | I don’t | no need | I don’t have anything |
Healthy | everything is fine | we are all okay | I’m fit as a fiddle | there is no problem |
Sick | I’m sick | quite feverish, yes | I have COVID | I really am tired |
After filling up the intents, press the Test button in order to train the classifier.
Now everything is ready for you to create and launch your first campaign.