Intent Conditions - Cognigy Documentation

Intent Conditions

Intent Conditions allow you to dynamically enable or disable a specific Intent based on real-time data. You can define them using CognigyScript and extend them with JavaScript. By default, AI Agents evaluate all available Intents. However, in some cases, certain Intents should only be considered under specific conditions. For example:

With Intent conditions, you can control when an Intent is active, improving the accuracy and relevance of AI Agent responses.

Key Benefits

How to Use

To set a condition for a specific Intent, navigate to NLU > Intents in the Flow editor. Open the Intent, then go to Advanced > Condition to configure the condition. If no condition is set, the Intent is always available.

Syntax

You can define Intent conditions using CognigyScript:

Single Condition
A single Intent condition is an expression that evaluates to true or false. The AI Agent will detect the Intent only if the condition is true. The !! operator ensures the value is evaluated as a boolean.
Examples: Check if the Keyphrase of the first item in the city Slot is equal to Düsseldorf:

!!(input.slots.city[0].keyphrase === "Düsseldorf")

Check if the topics array in the Context object doesn’t include the term Cognigy:

!!(!context.topics.includes("Cognigy"))

Multiple Conditions
To apply multiple Intent conditions, combine them using logical operators:

Examples: Enable Intent if the user asks about Düsseldorf and the topic is Cognigy:

input.slots.city[0].keyphrase === "Düsseldorf" && context.topics.includes("Cognigy")

Enable Intent if the user asks about Düsseldorf or Cognigy:

input.slots.city[0].keyphrase === "Düsseldorf" || context.topics.includes("Cognigy")

Use Cases

Restricting an Intent Based on User Profile
A bank AI Agent should allow users to cancel their credit cards only if they have one.
Condition:

!!(profile.has_credit_card)

Result: the Intent is only active for users with a credit card.

Checking Multiple Profile Attributes
The AI Agent should allow credit card cancellation only if the user owns a card that is activated.
Condition:

profile.has_credit_card === true && profile.credit_card_activated === true

Result: the Intent is enabled only for customers with an active credit card.