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)

circle-check

Configuration

Platforms

Platform
Supported

Messenger

WhatsApp

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.

class MainContext < Conversation

  def blocks

    intent "greeting" do
      @reply.text "Hello!"
    end

    intent "godbye" do
      @reply.text "Bye bye!"
    end

    intent "thanks" do
       @reply.text "You're welcome"
    end
  
end

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.

Wit.ai screenshot

In the code below, thanks to these parameters the block can send an even more appropriate reply:

Params definition

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 Block

Catch any intent of the message and returns 5 parameters: intent, text, entities, traits and confidence.

Usage

circle-check

Routing to Context

Last updated

Was this helpful?