Categories:
Nlp recognizer middleware
Description of nlp-recognizer-middleware, responsible for calling an external API in an attempt to obtain the user’s intent.
Introduction
The main objective of the recognizer is to call aura-nlp API and process its response.
The environment variable AURA_COGNITIVE_ENDPOINT contains the URL of Aura NLP API.
It should not be requested from outside the NLP recognizer.
Aura NLP will not be requested if the channel is not configured to use it. This is configured in the channel collection in the Aura Configuration API:
{
"name": "movistar-plus",
"prefix": "mp",
"nlp": {
"enabled": false
}
}
In this case, the NLP Recognizer will return an intent None with a score of 1.0. in the IntentResult.
Further information regarding channels’ configuration can be found in the Channels section. The source code of this recognizer is included in Aura Bot Platform recognizers - Github repository.
Disambiguation case
In aura-bot platform, NLP response is processed and formatted in the nlp-recognizer-middleware. In this middleware, a request to the domainClassifier API is executed:
domainClassifier = (await nlpApi.domainClassifierDefaultQuery(domainClassifierDefaultRequest, correlator, options)).body;
The response received in case there is disambiguation has the following structure:
{
query: 'original Phrase',
channel: 'mp',
intent_result: {
entities: [],
top_result: { intent: 'intent.disambiguation', score: 1.0 },
intents: [
{ intent: 'intent.disambiguation', score: 1.0 }
]
},
domain_result: {},
options: [
{
query: 'original Phrase',
channel: 'mp',
intent_result: {
entities: [
{
entity: '14', type: 'faq', score: 0.90, start_index: 1, end_index: 1, canon: '14', label: null
}
],
intents: [
]
},
domain_result: {},
options: []
}
]
}
As for the disambiguation case, information about the recognition process is obtained from the value options: [] shown in the example above. Otherwise, recognition’s response will be captured from the value intent_result: {}.
This value will be formatted and propagated into other components using the actual context:
ContextUtils.setIntentResult(context, result, context.activity.text, true)
Where result.entities will be formatted to avoid missing or empty arrays.
Following with the disambiguation example, information regarding it will be stored in result.disambiguationOptions with the following type IntentResult[].