For more information, refer to GitHub.
What Does This Plugin Do?
Botonic Plugin NLU allows you to predict intents from the user inputs for your bot.
To set up a new example using Botonic Plugin NLU, you can create a bot by running the following command:
Alternatively, if you already have a project, you can follow the steps below to setup it up.
Install the plugin
- From your project, enter the command
npm install @botonic/plugin-nlu. This command installs everything necessary to start working with your intents and entities. Note: Windows users should first use the command
npm install --global --production windows-build-tools --vs2015followed by
npm install @botonic/plugin-nlu
- Under the
srcfiles of your project, create a folder called
Require the Plugin
You must require the plugin in
src/plugins.js to be able to predict the intent of user inputs. You must set its
id to nlu for the plugin to work.
In case that you have trained your model with default preprocessing engines, you only need to specify the languages that you want to support.
Otherwise, you must load also the preprocessing engines for every language used to train your models.
- Under the
nlufolder, create a folder called
utterances, which will contain your multilingual intents.
- For every language you want to support, create a folder under
/src/nlu/utteranceswith its language code (it must be ISO 639-1). Ex: Training for English (
en), will result in the following path:
- Add a text file for each intent you want to create by naming them
- Fill them with possible ways to express each intent. Every sentence must be on a different line of the file. See Natural Language Understanding section for more information.
Train the Bot
Now it's time to order Botonic NLU to train each intent with the provided sentences:
Alternatively you can also run
npm run train.
After this, the bot will be able to run predictions on new inputs.
Every time you make changes in your utterances, you will need to run again the command above so that the changes take effect.
Define Routes with Intents
Once you've defined your intents, you can use them in the routes in the same way you use
payloads, and the like.
Below, we see how we might use them:
botonic serveto see how the bot runs in the development environment.
- For further details of the variables stored during the execution, open the
Botonic Dev Consoleby clicking on the tab in the top-left corner.
- Deploy your bot with
botonic deploy. You got a bot with a customized intent and entity recognition system!
The pre-trained word embeddings below are supported, which means that you can train your bot in these specific languages. For more information about other supported languages, feel free to contact us on Slack.
You can also generate your own word embeddings following these instructions.
*10k-fasttext word embeddings contain the 10k most commons words of the language.
Note: All the word embeddings are stored by default in
~/.botonic/word-embeddings/. If you encounter any issues when automatically downloading word embeddings, you can download them manually and store them in the mentioned directory.