Skip to main content

intentGroup

The intentGroup trigger tag declares nested intents by which the dialog can enter a state. The parent intent, specified after the tag, does not activate the state.

If you want the dialog to enter a state by the parent intent, use a separate intent tag for it:

state:
intentGroup: /Example
intent: /Example
tip
intentGroup is a local tag: transitions by this tag can be made only from the nearest parent, sibling, or children states.

Value

A path to the intent is specified after the tag. Within the path, / is a separator between nesting levels:

  • /hi — the path consists of the / character and the intent name.
  • /hi/politely — a nested intent. There is no upper limit to the nesting depth.

Parameters

ParameterTypeDescriptionDefault value
fromStateStringA path to a state from which a transition to the current state by this intentGroup tag can be made.
toStateStringA path to a state to which a transition from the current state by this intentGroup tag can be made.
onlyThisStateBoolean• If true and the fromState parameter is present, a transition to the current state can be made strictly from the state specified in fromState, but not from its nested states.
• If true and the toState parameter is present, a transition to the state specified in toState can be made strictly from the current state, but not from its nested states.
false

How to use

state: Start
q!: $regex</start>
a: Hello! Would you like to buy our course?

state: Yes
intent: /Yes
a: Do you want to pay for the course all at once or in installments?

# Depending on the user’s response,
# the `Courses/Price/Pay at once` intent or the `Courses/Price/Pay in installments` intent will trigger.

state: CoursesPayment
intentGroup: /Courses/Price
script: $faq.pushReplies();

state: No
intent: /No
a: Okay. If you change your mind, please let me know!

# The ChangeMind state will be activated
# for users who refused to pay for the course but changed their mind later and asked about it.

state: ChangeMind
intentGroup: /Courses || fromState = "/Start/No", onlyThisState = true
a: Have you changed your mind? That’s great! I’ll tell you all about it now.
script: $faq.pushReplies();

# All nested intents included in the intentGroup tag have the same priority.
# If a request with the same weight matches several nested intents, a random intent will be triggered:

state: CoursesGeneralQuestions
intentGroup: /Courses
# Nested intents: `/Courses/Start time` and `/Courses/Start date`.
# The request “When does the course start?” has the same weight for both intents, so either one can work.
script: $faq.pushReplies();

State triggering priority

If the intents paths overlap or match, the state activation order may change:

  • When using intentGroup or intentGroup!.

  • When using intentGroup and intent or similar global tags together.

  • When the nlp.considerContextDepthInStateSelectionV2 setting is activated in the chatbot.yaml file.

There are some regularities:

  • The higher the nesting intent level, the higher the state priority.

    In the example below, if the Courses/Price/Pay at once intent is recognized, then the CoursesPrice state will be activated.

    state: Courses
    intentGroup: /Courses
    script: $faq.pushReplies();

    state: CoursesPrice
    intentGroup: /Courses/Price
    script: $faq.pushReplies();

    Let’s look at the script example below, where the global intentGroup! tag is used to connect the knowledge base to the script. Let’s assume the /KnowledgeBase/FAQ.Courses/Price intent is recognized:

    • The PriceInt state will be activated because it has the intent! tag. It will have the highest priority.
    • The priority of the FAQ.Courses state will be lower because it can only be activated by the intentGroup! tag.
    • The AllFaqs state will have the lowest priority because it is activated by the most general group.
    • The Price state will not activated at all: KnowledgeBase/FAQ.Courses/Price is the parent intent.
    state: AllFaqs
    intentGroup!: /KnowledgeBase
    a: I found the answer in my knowledge base.
    script: $faq.pushReplies();

    state: FAQ.Courses
    intentGroup!: /KnowledgeBase/FAQ.Courses
    a: Are you interested in our courses? I found the answer for you.
    script: $faq.pushReplies();

    state: Price
    intentGroup!: /KnowledgeBase/FAQ.Courses/Price
    script: $faq.pushReplies();

    state: PriceInt
    intent!: /KnowledgeBase/FAQ.Courses/Price
    script: $faq.pushReplies();
  • If the request matches both an intent and an intentGroup in different states, the state that activates the intent tag will have priority.

    state: CoursesUnknown
    intentGroup: /Courses
    a: Apparently, you asked me about our courses, but I didn’t understand you. I have not yet been trained to answer such questions.

    state: CoursesDate
    intent: /Courses/Start date
    a: There is no fixed start date for the course. You can join the course whenever it suits you.

    The user’s request When does the course start? may match both states, but the one with intent is activated. It has a higher priority. The bot will respond with a more specific response, not a mock response.

  • The nlp.considerContextDepthInStateSelectionV2 property in the chatbot.yaml file can affect the order in which the states are triggered. If set to true, the bot takes into account the context distance to the state, so intentGroup in a nested state has an advantage over other intents:

    state: Start
    q!: $regex</start>
    a: Hello! It seems you want to buy our course.

    state: PayInInstallments
    intentGroup: /Pay in installments
    a: I’ll explain how to buy our course by installments.

    state: PayAllAtOnce
    intentGroup: /Pay all at once
    a: Let me explain how to pay for our course all at once.

    The bot is in the Start state. The How to pay for the course all at once? request has a weight of 1 for the /Pay all at once/How to pay all at once? intent and 0.3 for the /Pay in installments/How to pay in installments? intent. If true, the PayInInstallments nested state will be activated, and the bot will explain how to buy the course in installments. If false, state nesting does not affect the order in which they are triggered, so the PayAllAtOnce state will be activated. The bot will explain how to pay for the course all at once.