Skip to content

Using NLP.js

jordicabot edited this page Oct 5, 2020 · 5 revisions

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 xatkit/xatkit-nlp.js-server:latest
docker run -p 8080:8080 -d xatkit/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, just 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.nlpjs.agentId = default
xatkit.nlpjs.language = ca
xatkit.nlpjs.server = http://localhost:8080
Clone this wiki locally