-
public interface NlpListenerUsed to customize behaviour of NLP parsing - and also to monitor NLP requests - on bot side. Has to be registered using ai.tock.bot.engine.BotRepository.registerNlpListener.
-
-
Method Summary
Modifier and Type Method Description IntenthandleKeyword(String sentence)Used to handle "secret" keywords. IntentAwarefindIntent(UserTimeline userTimeline, Dialog dialog, Event event, NlpResult nlpResult)This method is automatically called by the bot after a NLP request in order to select an intent. List<EntityValue>evaluateEntities(UserTimeline userTimeline, Dialog dialog, Event event, NlpResult nlpResult)Allows custom entity evaluation - default returns empty list. List<NlpEntityMergeContext>sortEntitiesToMerge(List<NlpEntityMergeContext> entities)Defines custom sort new entity values. NlpEntityMergeContextmergeEntityValues(DialogState dialogState, Action action, NlpEntityMergeContext entityToMerge)Allows to override NlpEntityMergeContext before trying to merge the entity context. Unitsuccess(NlpQuery query, NlpResult result)Called when nlp request is successful. Uniterror(NlpQuery query, Dialog dialog, Throwable throwable)Called when nlp request is throwing an error. -
-
Method Detail
-
handleKeyword
Intent handleKeyword(String sentence)
Used to handle "secret" keywords.
-
findIntent
IntentAware findIntent(UserTimeline userTimeline, Dialog dialog, Event event, NlpResult nlpResult)
This method is automatically called by the bot after a NLP request in order to select an intent. Overrides it if you need more control on intent choice.
If it returns null, ai.tock.bot.definition.BotDefinition.findIntent is called.
Default returns null.
-
evaluateEntities
List<EntityValue> evaluateEntities(UserTimeline userTimeline, Dialog dialog, Event event, NlpResult nlpResult)
Allows custom entity evaluation - default returns empty list.
-
sortEntitiesToMerge
List<NlpEntityMergeContext> sortEntitiesToMerge(List<NlpEntityMergeContext> entities)
Defines custom sort new entity values. This is useful when you want to evaluate an entity role only after an other entity role has been evaluated (entity dependence use case). Default does nothing.
-
mergeEntityValues
NlpEntityMergeContext mergeEntityValues(DialogState dialogState, Action action, NlpEntityMergeContext entityToMerge)
Allows to override NlpEntityMergeContext before trying to merge the entity context.
-
error
Unit error(NlpQuery query, Dialog dialog, Throwable throwable)
Called when nlp request is throwing an error.
Using this method, you can for example redirect to a custom story which will handle the error.
object MyNlpListener : NlpListener { override fun error(query: NlpQuery, dialog: Dialog, throwable: Throwable?) { super.error(query, dialog, throwable) dialog.state.currentIntent = bot.myCustomErrorStory.mainIntent() } }
-
-
-
-