Skip to content

Condition - Lex 2

0

I want to define a condition in Amazon Lex V2 that checks if a slot contains a value. I am using Lex2 and the following format to define conditions:

fn.IS_SET({matricula}) = "TRUE"

When building the bot, I'm getting this error:

Invalid conditional expression in slot 'dni' of intent 'DarMatriculaDNI'. Invalid expression: fn.IS_SET({matricula}) = "TRUE"

Both slots {matricula} and {dni} are in the same intent DarMatriculaDNI. What am I doing wrong?

asked a year ago149 views
2 Answers
1

The issue with your conditional expression in Amazon Lex V2 is that the fn.IS_SET() function is a Boolean function that returns true or false, and it should not be compared to a string ("TRUE"). Instead, you should directly use it in your condition.

Correct Expression:

fn.IS_SET({matricula})

For negation:

!fn.IS_SET({matricula})

I don't know why the re:Post Agent said:

Secondly, the IS_SET() function is used without the "fn." prefix in Lex V2 conditional expressions.

But it was clearly written on the documentation that: Enter image description here

Other Common fn. Functions

**Function** Description
fn.IS_SET({slot_name})Checks if a slot is filled.
fn.EQUALS({slot}, "value")Compares a slot value with a given value.
fn.CONTAINS({slot}, "substring")Checks if a slot value contains a substring.
fn.AND(condition1, condition2)Returns true if both conditions are true.
fn.OR(condition1, condition2)Returns true if at least one condition is tr.
answered a year ago
-2

Thank you for providing the details about your issue with defining a condition in Amazon Lex V2. It appears there are a couple of issues with the conditional expression you're using.

First, the function IS_SET() in Amazon Lex V2 doesn't require comparison to "TRUE". The function itself returns a boolean value, so you can use it directly without the equality comparison.

Secondly, the IS_SET() function is used without the "fn." prefix in Lex V2 conditional expressions.

To correctly check if a slot contains a value, you should use the following format:

IS_SET({matricula})

This expression will evaluate to true if the 'matricula' slot has a value, and false if it doesn't.

If you want to combine this with other conditions, you can use boolean operators. For example:

IS_SET({matricula}) AND {dni} = "some_value"

Make sure that both 'matricula' and 'dni' slots are defined in your 'DarMatriculaDNI' intent. If you're trying to use a slot from a different intent, you would need to specify the intent name as well, like this: {IntentName.SlotName}.

By making these adjustments, your conditional expression should work correctly in your Amazon Lex V2 bot.
Sources
Add conditions to branch conversations - Amazon Lex
Set values during the conversation - Amazon Lex

answered a year ago
  • IS_SET({matricula}) does not work. I am getting this error: Invalid conditional expression in slot 'dni' of intent 'DarMatriculaDNI'. Invalid expression: IS_SET({matricula})

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.