Use @Condition
The condition property
In the Javascript of the competency, we use the conditions property:
import code from './main.converse'
export default {
code,
conditions: {
authorize(data, user) {
return user.variables.token;
}
}
}The key is the name of your condition (here authorize), the value is a function with two parameters:
</api-table>
Use in the conversational script
The decorator @Condition is accompanied by another decorator.
$token = ''
@Condition('authorize')
@Intent(/forbidden/i)
forbidden() {
> It's ok !
}In the code above, the function forbidden will be triggered if: 1. The user says forbidden 2. The authorize condition returns true. Here, the token global variable must have a value
Of course, we could have done the same thing with the
ifcondition directly in the script. The decorator@Conditioncan be very interesting to perform functions according to the platform. We will therefore use the parameterdata
Last updated
Was this helpful?