User Guide
API DOCSVOICE GATEWAYHELPSECURITY
Current Version
Current Version
  • Welcome
  • What's New
  • 🚀GETTING STARTED
    • Login
    • Concepts and Glossary
    • Language Models
      • Syntphony NLP
      • Other NLP and LLM Connectors
      • FAQs
    • Build a Virtual Agent
      • Overview
      • From Scratch
      • By Importing
      • Pre-Built Templates
      • Training task
    • Testing
      • Automated Test
      • Advanced Request
      • Simulate Dialog
      • View Logs
    • Create and manage profiles
  • 💬BUILD DIALOGS
    • Flows
    • Dialog Cells
      • Intent
      • Entity
      • Answer
      • Input
      • Jump
      • End
      • Service
      • Rest Connector
      • Code
      • Rule
        • Variable answers using Code and Rule cells
        • Enable and disable flows using Rule Cells
    • Data Masking of Personal Identificable Information
    • Dynamic Content and Contexts
    • Voice Agent
    • Multilingual Agent (beta)
  • ✨GENERATIVE AI
    • AI features
    • Assist Answer (beta)
    • Examples Generator
    • Knowledge AI
    • Prompt cell
      • Prompt crafting
      • Practical examples
    • Rephrase Answer
    • Zero-Shot LLM
  • 🌐CHANNELS
    • Channels
      • WhatsApp (by Infobip)
      • Facebook Messenger
      • Microsoft Teams
      • Integrating Existing Channels
    • Webchat Plugin
  • ⚙️CONFIGURATIONS
    • Parameters
    • Advanced Resources
    • Other Options
      • Intent Navigator
  • 📊ANALYTICS & INSIGHTS
    • Dashboards
      • Overview
      • Funnel charts
      • User messages
      • Conversations
      • Reports
    • External Analytics Platforms
  • API DOCS
    • Overview
    • API Guidelines
      • Conversation API
      • Cloner API
      • EVG Connector
      • Management API
        • Admin API
          • Bot Admin
          • Environment
          • Organization
          • User
          • Notification
        • Instance API
          • Knowledge AI
          • Knowledge AI NLP
          • Answer
          • Automated Tests
          • Bot
          • Broker
          • Channel
          • Dashboard
          • Dialog Manager
          • Entity
          • Generative Service
          • Intent
          • Parameters
          • Tag
          • Technical Log
          • Training
          • Transactional Service
          • Rest Connector
          • Wait Input
          • Websnippet
      • Webhooks
    • Infrastructure Guidelines
      • Syntphony CAI server Installation guide
      • Maintenance Methods
      • Supported/verified third-party software
    • Data Structure
      • Admin Data Structure
      • Environment Data Structure
    • Voice Gateway
      • Genesys Cloud CX
Powered by GitBook
On this page

Was this helpful?

  1. BUILD DIALOGS
  2. Dialog Cells
  3. Rule

Variable answers using Code and Rule cells

PreviousRuleNextEnable and disable flows using Rule Cells

Last updated 8 months ago

Was this helpful?

Variable Answers

With Syntphony CAI, 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