just-ai/jaicf-kotlin

Add match event

Denire opened this issue · 3 comments

NLU Providers can contain default answer for intent, which can be extracted from ActivatonContext in scenario and responded. Example usage:

state("handler") {
    activators {
        intent("HowAreYou")
    }
    action {
        activator.caila?.topIntent?.answer?.let {
            reactions.say(it)
        }
    }
}

It looks ok when there's not so many intents. But when intents number increases, usability decreases. User should list all project intents in single state and he cannot separate dialogue logic from scenario.

state("handler") {
    activators {
        intent("HowAreYou")
        intent("WhatCanYouDo")
        intent("Family")
        intent("WhatAreYouDoing")
        ...
    }
    action {
        activator.caila?.topIntent?.answer?.let {
            reactions.say(it)
        }
    }
}

This issue suggest adding something like:

state("handler") {
    activators {
        event(Activations.AnyActivation)
    }
    action {
        activator.caila?.topIntent?.answer?.let {
            reactions.say(it)
        }
    }
}

Isn't it the case for BeforeProcessHook?

Don't think so:

  1. It's better to keep scenario logic inside scenario, but not in hooks.
  2. BeforeProcessHook may receive CatchAllActivatorContext instead of real context, because no state was found, as no state has activator with specified name.

I agree with your points, but as I understand from your examples it doesn't look like scenario logic, it looks exactly like hook logic as you want to react on some global events like "Any activation". Correct me please, if I'm wrong.
EDIT: I've misunderstood you, it's a scenario logic and should be implemented as a feature, thanks for the explanation @Denire .