User Guide
eva 3.4.1
eva 3.4.1
  • Home and Support
  • What's new
  • Changelog
  • Using eva
    • Overview
      • Virtual Agents
      • Main Concepts of eva
      • Glossary
    • Developing virtual agents
      • Quick Start with eva
      • Dialog Flows
      • Dialog Cells
        • Intent Cells
        • Entity Cells
        • Answer Cells
        • Service Cells
        • Input Cells
        • Jump Cells
        • End Cells
        • Code Cells
        • Rule Cells
      • Training task
      • Export and import agents
      • Create virtual agents from templates
      • Create and manage users
    • Channels
      • Integrating Existing Channels
    • Testing Virtual Agents
      • Test a virtual agent
      • Automated Test
    • Natural Language
      • eva NLP
      • Training with eva NLP
      • Training with eva Automated Learning
      • Using other NLP engines
    • Analytics
      • External analytics platforms
    • Experience
      • Context Management
    • Advanced Options
      • Parameters
      • Intent Navigator
      • PII Data masking
    • How Tos
      • Creating variable answers with Code and Rule cells
      • Videos
  • for technicians
    • eva server Installation guide
    • API Guidelines
      • Conversation API
      • Cloner API
      • Webhooks
    • Supported/verified third-party software
    • Appendices
    • Data Extraction
Powered by GitBook
On this page
  1. Using eva
  2. How Tos

Creating variable answers with Code and Rule cells

PreviousHow TosNextVideos

Last updated 2 years ago

Variable Answers

With eva, it is possible to predict in your flow different responses for the same Intent. The mechanism can be very useful in several use cases in dialogs.

For example, in the dialog below:

User message: What are the required documents to open a bank account?

Virtual agent answer 1: I am glad to know that you want to open an account at Bank XYZ! The documents required are ID, proof of residence, proof of income, and an up-to-date photo.

Now, imagine that the user spends some time talking to the virtual agent and repeats the same question. In this case, the virtual agent can vary the answer, for example:

Virtual agent answer 2: I’ve got it! No problem, I can give you the information again ;-) The required documents are ID, proof of residence, proof of income, and an up-to-date photo.

Important: To create Variable Answers, you will need to use and cells. Learn more about them at the links 😉

There are two types of Variable Answers:

I) Sequential: as the name suggests, it delivers the answers in sequence, from the first predicted answer to the last one.

To create them, you need to create a Code cell and a Rule cell for each answer, as illustrated in the image below:

In cases of sequential answers, the code in the Code cell will always be:

if (hiddenContext.seq == null || hiddenContext.seq == number of answers)
	hiddenContext.seq = 0
else
  hiddenContext.seq++;

For example, if three (3) sequential answers are predicted, the code will be:

if (hiddenContext.seq == null || hiddenContext.seq == 3)
	hiddenContext.seq = 0
else
  hiddenContext.seq++;

If eleven (11) sequential answers are predicted, the code will be:

if (hiddenContext.seq == null || hiddenContext.seq == 11)
	hiddenContext.seq = 0
else
  hiddenContext.seq++;

And the Rule cell codes will vary in this way:

For the first answer:

hiddenContext.seq == 0

For the second answer:

hiddenContext.seq == 1

If you want to add other answers, simply change the number in the code (2 for the third answer, 3 for the fourth answer, 4 for the fifth answer, and so on).

II) Random: Also as the name suggests, it delivers answers randomly. To create them, you need to create a Code cell and a Rule cell for each answer, as illustrated in the image below:

In cases of random answers, the code in the Code cell will always be:

hiddenContext.seq = Math.floor(Math.random() * number of answers);

For example, if three (3) random answers are predicted, the code will be:

hiddenContext.seq = Math.floor(Math.random() * 3);

If eleven (11) random answers are predicted, the code will be:

hiddenContext.seq = Math.floor(Math.random() * 11);

And the codes in the Rule cells will vary like this:

For the first answer

hiddenContext.seq == 0

For the second answer

hiddenContext.seq == 1

If you want to add other answers, simply change the number in the code (2 for the third answer, 3 for the fourth answer, 4 for the fifth answer, and so on).

Tip: Using this same method, you can also perform A/B Tests

In this case, the code cell will always be:

hiddenContext.seq = Math.floor(Math.random() * 100);

The rule cell codes, on the other hand, will be:

Answer A

hiddenContext.seq <= 50

Answer B

 hiddenContext.seq >= 50

To get the metrics of which answer did better, you need a webhook. There are two alternatives: Either predict a (with webhook) on each response that will be evaluated or provide a in the flow.

transactional answer
Service cell
Code
Rule