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.
intent(name=String|Array, &block)
intent(name=String|Array, &block)
Configuration
The NLP engine must be enabled and configured in bot/config/nlp.rb
file in order to implement this block.
Platforms
Platform | Supported |
---|---|
Messenger | |
Telegram |
Usage
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.
Example of how they look in Wit.ai
As we mention before, each intent must has been created and trained in the NLP Engine (in this case Wit.ai)
Reading Params
This block passes 4 parameters that are: text
, entities
, traits
and confidence
, which contain additional information to the intention itself.
Usage example
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:
Params definition
text
text
Just the text message "Please wake me up tomorrow at 7am. I'd really appreciate it"
entities
entities
Array with the entities found.
traits
traits
Array with the traits found.
confidence
confidence
The percentage of confidence of the NLP engine in associating the message with the intent.
0.998
any_intent
Block
any_intent
BlockCatch any intent of the message and returns 5 parameters: intent
, text
, entities
, traits
and confidence
.
Usage
Routing to Context
An intent can be routed to a specific context, learn how in Routing Chapter.
Last updated