-
Notifications
You must be signed in to change notification settings - Fork 22
Using NLP.js
NLP.js is a NLP library for building bots, with entity extraction, sentiment analysis, automatic language identify, etc.
We can use nlp.js as an intent recognition provider for Xatkit. Compared to our DialogFlow integration, nlp.js natively supports a broader set of languages and it is executed locally instead of relying on ane external cloud-based API.
At the technical level, the connector is implemented as a Node app that uses Express to expose a REST API that can manipulate an NLP.js engine. Then, we have added a new Intent Recognition Provider that communicates with the nlp.js server to process the user inputs.
To use nlp.js in your bot, you first need to install this Node server. We recommend using Docker for this. Our NLP.js server is available at Docker hub. Follow the instructions below to download it and run it:
docker pull xatkitdocker/xatkit-nlp.js-server:latest
docker run -p 8080:8080 -d xatkitdocker/xatkit-nlp.js-server
This will run the server on the port 8080. Check the installation at http://localhost:8080. The server exposes a default agent called default that you can use in your bot (you can create additional ones).
Then, add the following dependency in your pom.xml
file:
<dependency>
<groupId>com.xatkit</groupId>
<artifactId>xatkit-nlpjs</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
Finally, add the following properties to your bot configuration file (‘ca’ is the standard language code for Catalan, so in this example the bot will be able to speak Catalan):
xatkit.intent.provider = com.xatkit.core.recognition.nlpjs.NlpjsIntentRecognitionProvider
xatkit.nlpjs.agentId = default
xatkit.nlpjs.language = ca
xatkit.nlpjs.server = http://localhost:8080
Note that you can use static constants to set these values if you are working with a configuration object (and not a file):
botConfiguration.addProperty(IntentRecognitionProviderFactory.INTENT_PROVIDER_KEY, NlpjsConfiguration.NLPJS_INTENT_PROVIDER);
botConfiguration.addProperty(NlpjsConfiguration.AGENT_ID_KEY, "default");
botConfiguration.addProperty(NlpjsConfiguration.LANGUAGE_CODE_KEY, "ca");
botConfiguration.addProperty(NlpjsConfiguration.NLPJS_SERVER_KEY, "http://localhost:8080");
- Getting Started
- Configuring your bot
- Integrating an Intent Recognition Provider
- Adding a bot to your website
- Deploying on Slack
- Basic concepts
- Intents and Entities
- States, Transitions, and Context
- Default and Local Fallbacks
- Core Library