CDQA skills
Beta
The CDQA (Closed Domain Question Answering) is a question answering system based on machine learning. You can upload a text file to it, and the bot can use excerpts from this file to answer user questions.
To start working with the CDQA:
Create the CDQA
Go to the necessary project.
Select Knowledge base on the control panel.
If the knowledge base already contains modules, click Add module on the tab bar.
Select CDQA and configure the module:
Enter the CDQA name.
Select the document language: Russian and English or other languages.
Upload the document where the bot should retrieve answers from.
cautionDocument file requirements: TXT format, UTF-8 encoding, size up to 1 MB.
Select Add module.
Connect the CDQA to the script
Go to the knowledge base menu.
Find the CDQA module and click next to it → Copy the module code.
Select Editor → Code on the control panel.
Paste the code you’ve copied at the end of the script. Here’s how it looks:
state: NoMatch
event!: noMatch
script:
var result = $caila.cdqaQuery($request.query, "CDQA.Our courses", 0.5);
if (result.predicted) {
$reactions.answer(result.predicted);
} else {
$reactions.answer("I didn’t find the answer in my documents. Ask something else!");
}This is a state where the bot will switch to by the
noMatch
event: when it cannot find the answer to a user’s question in FAQ modules or among other CAILA intents. In this state, the bot calls a special$caila.cdqaQuery
method to retrieve the answer from the CDQA.tipThere should only be one state withevent!: noMatch
in the script. If a state like this already exists, either delete it or adapt its code to call$caila.cdqaQuery
.
You can use response retrieval from the CDQA in any other place in the script. For example, if the user request is relevant to an FAQ module, the bot can look up an answer in the document and only use the default answer from the FAQ if it can’t find any:
state: FAQ.Education
intentGroup!: /KnowledgeBase/FAQ.Education
script:
var result = $caila.cdqaQuery($request.query, "CDQA.Our courses", 0.5);
if (result.predicted) {
$reactions.answer(result.predicted);
} else {
$faq.pushReplies();
}