If
Annotation | <If> |
---|---|
Definition | Conditional evaluation of patterns or children elements. |
Children | content |
Attributes | Required Bot , User or Var attribute |
Optional Variable Operators Symbols that specify which operations to perform. | |
Occurrence | One or more <If> elements MAY occur as descendants of <Response> element. |
The If element controls the generation of responses if certain conditions are met. Usually the conditions are states of predicates/variables or comparison of their values.
Example - SIML Classic
<Model>
<Pattern>AM I OLD ENOUGH</Pattern>
<Response>
<If User="age" Value="18">Yes you are.</If>
<ElseIf User="Age" Value="40">you are 40 years old. So definitely yes.</ElseIf >
</Response>
</Model>
Example - SIML Modern
<Intent>
<Expression Value="Am I old enough?"/>
<Response>
<If User="age" Value="18">Yes you are.</If>
<ElseIf User="Age" Value="40">you are 40 years old. So definitely yes.</ElseIf >
</Response>
</Intent>
User Input
Am I old enough?
Bot Output
Yes you are.
Explanation
The Bot responds Yes you are if and only if the bot had stored the user’s age and it was set to 18. In this example we used User as the entity whose variables/predicates are to be evaluated. You can also use Bot element to compare bot variables.