| title | excerpt | url |
|---|---|---|
NLU Integrations |
Learn more about natural language understanding (NLU) services that can be integrated with Jovo. |
Learn more about natural language understanding (NLU) services that can be integrated with Jovo.
Natural language understanding (in short, NLU) is the process of turning raw text into structured meaning. It is part of the interpretation step of the RIDR lifecycle.
Jovo offers integrations with a variety of NLU services that can either be self-hosted or accessed via an API. You can find all the current integrations below.
NLU integrations are helpful for platforms that deal with raw text. The integration then writes the results into an nlu object that is part of the $input property:
{
type: 'TEXT',
text: 'My name is Max',
nlu: {
intent: 'MyNameIsIntent',
entities: {
name: {
value: 'Max',
},
},
native: {
// Raw API response from the NLU service
}
},
}Learn more about Jovo NLU integrations in the following sections:
Currently, the following integrations are available with Jovo v4:
- Snips NLU (comes with an open source server)
- NLP.js (default for Jovo Debugger)
- Rasa NLU
- Lex SLU
To enhance performance, you can also add the Keyword NLU plugin, which maps common keywords to intents before other NLU integrations are called.
An NLU integration needs to be added as a platform plugin in the app configuration. Here is an example how it could look like in the app.ts file:
import { CorePlatform } from '@jovotech/platform-core';
import { NlpjsNlu } from '@jovotech/nlu-nlpjs';
// ...
const app = new App({
plugins: [
new CorePlatform({
plugins: [new NlpjsNlu()],
}),
// ...
],
});Along with integration specific options (which can be found in each integration's documentation), there are also features that are configured the same way across all NLU integrations.
The default configuration for each NLU integration is:
new NlpjsNlu({
// ...
input: {
supportedTypes: ['TEXT', 'TRANSCRIBED_SPEECH', 'SPEECH'],
}
}),The input config property determines how the NLU integration should react to certain properties. supportedTypes include all input types for which the NLU integration should run.
- Speed: Increase response times by removing unnecessary NLU service calls
- Intent Scoping: Increase accuracy by prioritizing intents for some requests
The NLU integration calls the respective NLU service/API for every request that includes a text and fulfills the supportedTypes configuration. Each request costs time and potentially money, depending on the service.
For keywords that are used often (for example yes/no, or words that show up in quick replies), it can be costly to call an NLU service each time a request contains straightforward input like this.
To enhance performance, you can add the Keyword NLU plugin in addition to a regular integration. The plugin maps common keywords to intents before other NLU integrations are called.
import { App } from '@jovotech/framework';
import { KeywordNluPlugin } from '@jovotech/plugin-keywordnlu';
// ...
const app = new App({
plugins: [
// Used for common keywords
new KeywordNluPlugin({
keywordMap: {
yes: 'YesIntent',
no: 'NoIntent',
'learn more': 'LearnMoreIntent',
},
}),
// ...
],
});Some NLU services support the ability to prioritize certain intents. You can do so by adding a list of intent names to the listen output property:
{
message: `Which city do you want to visit?`,
listen: {
intents: [ 'CityIntent' ],
},
}After adding intents to an output template, the following happens:
- The array gets stored in a
_JOVO_LISTEN_INTENTS_session variable in theafter.response.outputmiddleware. When there are multiple output templates in the$outputarray that haveintentsas part oflisten, the values will get merged. - During the next request, the list will be passed to the NLU service and taken into account when parsing input.
Currently, this feature is supported by Snips NLU.
Each plugin that aims to support intent scoping needs to implement the supportsIntentScoping() method (used by InterpretationPlugin to determine whether data should be stored).
supportsIntentScoping(): boolean {
return true;
}