# botbuilder-nlpjs

> Middleware to delegate to nlp.js from Microsoft Botbuilder and Botkit

Latest version **1.1.1** (published 2021-02-21) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install botbuilder-nlpjs
pnpm add botbuilder-nlpjs
yarn add botbuilder-nlpjs
bun add botbuilder-nlpjs
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2021-02-21 |
| First published | 2021-01-04 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 42.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Russell Geraghty |
| Maintainers | notquiterussell |
| Keywords | nlp, bot-framework, microsoft-bot-framework, nlp-machine-learning, microsoft-bot-framework-v4, nlpjs, nlp.js, botkit |

## Links

- npm: https://www.npmjs.com/package/botbuilder-nlpjs
- Repository: https://github.com/notquiterussell/botbuilder-nlpjs
- Homepage: https://github.com/notquiterussell/botbuilder-nlpjs#readme
- Issues: https://github.com/notquiterussell/botbuilder-nlpjs/issues
- npm.io page: https://npm.io/package/botbuilder-nlpjs

## Dependencies (2)

- [node-nlp](https://npm.io/package/node-nlp.md) ^3.10.2
- [botbuilder](https://npm.io/package/botbuilder.md) ^4.11.0

## Recent versions

- 1.1.1 (latest) — 2021-02-21
- 1.1.0 — 2021-02-20
- 1.0.5 — 2021-02-19
- 1.0.4 — 2021-01-06
- 1.0.3 — 2021-01-04
- 1.0.2 — 2021-01-04

## README

# NLP.js based middleware for Microsoft Bot framework

This is a middleware plugin for the [Botkit](https://botkit.ai) part of the [Microsoft Bot framework](https://dev.botframework.com).

The plugin uses a local, private model via [NLP.js](https://github.com/axa-group/nlp.js/) to extract:
* Input classifications
* Intents for the given input
* The sentiment of the input
* Entities in the input (see the note below on entity analysis)
* Answers to the input, to allow building Question and Answer bots

Each one can be added individually to the bot, but they can all share the same bot model to reduce memory
consumption.

## Adding the middleware

To add the middleware first await the build of the NlpjsEngine, then instantiate the components you
wish to add. Finally, add the components to the required adapters.

Note that you will need a built model file to drive the NLP, see [this example](https://github.com/axa-group/nlp.js/blob/master/docs/v3/nlp-manager.md#saveload-using-files)
for how to build the required file.

```javascript
const { NlpjsEngine, Answer, IntentAnalysis, EntityAnalysis, LanguageAnalysis } = require('botbuilder-nlpjs');
// Other setup
NlpjsEngine.build({ languages: ['en'], forceNER: true }, path.join(__dirname, 'features', 'private.json')).then(
  nlpEngine => {
    // Note that there is nothing special about using the Slack adapter
    const adapter = new SlackAdapter({/* Slack setup options */});

    adapter.use(new Answer(nlpEngine));
    adapter.use(new IntentAnalysis(nlpEngine));
    adapter.use(new EntityAnalysis(nlpEngine));
    adapter.use(new LanguageAnalysis(["en", "de"], 3))

    // Final setup and run
  }
);
```


## Note on EntityAnalysis

For the entity analysis to work correctly the NlpjsEngine must be built using the setting `forceNER: true`,
for example:

```javascript
NlpjsEngine.build(
    { languages: ['en'], forceNER: true },
    path.join(__dirname, 'features', 'private.json')
  ).then(nlpEngine => {
  // Do stuff with the engine
});
```

## Build status

![Botbuilder-npmjs build status](https://github.com/notquiterussell/botbuilder-nlpjs/workflows/Node.js%20CI/badge.svg)

---
_Source: https://npm.io/package/botbuilder-nlpjs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
