intent
This block will be executed if the intent provided as argument matches with the incoming message intent and if it was previously created and trained in the NLP engine.
Last updated
Was this helpful?
This block will be executed if the intent provided as argument matches with the incoming message intent and if it was previously created and trained in the NLP engine.
Last updated
Was this helpful?
intent(name=String|Array, &block)
The NLP engine must be enabled and configured in file in order to implement this block.
Messenger
Telegram
In the following example, MainContext
will handle 3 different intentions:
greeting
: Greeting messages like "Hi", "Hello" and so on.
goodbye
: Goodbye messages like "Bye", "GodBye", "Goodnight" and so on.
thanks
: Thank you messages like "Thanks", "Thank you", "I appreciate it" and so on.
As we mention before, each intent must has been created and trained in the NLP Engine (in this case Wit.ai)
This block passes 4 parameters that are: text
, entities
, traits
and confidence
, which contain additional information to the intention itself.
For the example below, let's assume the incoming message says the following:
"Please wake me up tomorrow at 7am. I'd really appreciate it"
Assuming also that we have been created and trained an intent called set_alarm
, that is linked to the entity wit/datetime
and the trait wit/sentiment
.
In the code below, thanks to these parameters the block can send an even more appropriate reply:
text
Just the text message "Please wake me up tomorrow at 7am. I'd really appreciate it"
entities
Array with the entities found.
traits
Array with the traits found.
confidence
The percentage of confidence of the NLP engine in associating the message with the intent.
0.998
any_intent
BlockCatch any intent of the message and returns 5 parameters: intent
, text
, entities
, traits
and confidence
.
An intent can be routed to a specific context, learn how in .