📃
NewBot
  • NewBot, what is it?
  • ConverseScript Syntax
    • Variables
    • Arithmetic
    • Boolean
    • Array and object
    • Entering text and output
    • Magic variables
    • Condition
    • Loop
    • Functions
    • The decorators
      • Use @Condition
      • Use @Action
      • Use @Format
      • Use @Intent
      • Use @Event
  • Prebuilt Formats for Widget
    • Quick Replies
    • Multi Cards
    • Articles
    • Form
  • Pre-built function for the widget
    • Request()
    • Map()
    • _ (lodash)
  • Get Started with Framework
    • Install
    • Main Skill
    • Write the conversational script
  • Use NewBot Framework JS
    • Create a skill (more details)
      • Relationship between skills
      • Use the functions of a child competency
      • Conditional
      • Control access to a skill
    • Create a JavaScript function and trigger it in ConverseScript
    • The constants
    • Write formats
      • Write and use multi-formats
      • Share formats
    • Internationalization (i18n)
    • Set up an NLP system
      • Share the NLP system
      • Use DialogFlow
    • Deploy on the browser
    • Run the chatbot on NodeJS
    • Send data when running the chatbot
    • The middlewares
    • Save the user's progress
    • User object
  • Unit Tests
    • Test a scenario
    • Test variables
    • Spy a function
    • Create a mock
    • Test the events
    • Test the actions
Powered by GitBook
On this page
  • Intentions
  • Use the native NLP
  • Create intentions with phrases to train.
  • Phrases in several languages.
  • Extract Entities

Was this helpful?

  1. ConverseScript Syntax
  2. The decorators

Use @Intent

Intentions

Depending on a user's intent, a function can be triggered. For this, we use the Intent() decorator. The easiest way is to use a regular expression:

@Intent(/hello/i)
hey() {
    > Hey
}

Use the native NLP

You can use the native NLP system to get away from third-party platforms.

Advantages

  • Independent of third party platforms (no need for DialogFlow or others)

  • You can integrate this system directly into the browser. Useful for creating an offline chatbot

Disadvantages

  • You have no visibility on the phrases used by the user. On third-party platforms, they record the new sentences in order to add them to the chatbot's understanding.

  • Extraction of entities (a place, the name of a person, etc.) is less elaborate

  • On the browser side, your chatbot will be heavier

this will generate different browser and server side code

Create intentions with phrases to train.

In the conversational script of the skill, let's use the Intent decorator to create an intent:

@Intent('buy.product', [
    'I want an ice cream',
    'I want to buy a coffee'
])
buyProduct() {
    > Ok, I take your order
}

@Intent('buy.stop', [
    'cancel my order',
    'delete my purchase'
])
buyStop() {
    > Ok, I cancel the order
}

Phrases in several languages.

You have two ways

Add languages ​​to the conversational script

In the conversational script, here's how we can add phrases per language

@Intent('buy.product', {
    fr: [
        'Je veux une glace',
        'Je veux acheter un café'
    ],
    en: [
        'I want an ice cream',
        'I want to buy a coffee'
    ]
})
buyProduct() {
    > Ok, I take your order
}

Add languages ​​to the .json file

  1. Follow the internationalization tutorial

  2. Let's add the identifiers in the table:

Assuming the file languages/en_EN.json is the following

[
    {
        "want_ice_cream": "I want an ice cream",
        "want_coffee": "I want to buy a coffee"
    }, 
    {
        "plurial": {
            "p": [
                "s"
            ]
        }
    }
]

Here is the conversational script:

@Intent('buy.product', [
    '#want_ice_cream',
    '#want_coffee'
])
buyProduct() {
    > Ok, I take your order
}

Extract Entities

Some entities are extracted. You can read them with the magic variable :entity:

@Intent('buy.product', [
    'By today'
])
buyProduct() {
    > Ok, date is { :entity.date.value }
}
PreviousUse @FormatNextUse @Event

Last updated 3 years ago

Was this helpful?