axa-group / nlp.js

An NLP library for building bots, with entity extraction, sentiment analysis, automatic language identify, and so more
MIT License
6.22k stars 616 forks source link

With the slot filling feature, how to cancel the question when user dont want to provide the rest of the entities. #352

Closed LordRobert closed 1 year ago

LordRobert commented 4 years ago

With the slot filling feature, consider this scene: user> I want to travel bot> Where do you want to go? user> London bot> From where you are traveling? user> Barcelona bot> When do you want to travel? user> tomorrow bot> You want to travel from Barcelona to London tomorrow

When the bot ask user second question: "From where you are traveling?", then user want to skip the question and finish this intent, how to interrupt this intent?

i have not find a way to do this.

I think there would be a way (maybe a center phrase, like "CANCEL CURRENT SOFTFILLING") can be provide to to achieve this.

holp to know what you thingk about this quesiton, and if there is already a solution to do this?

ericzon commented 4 years ago

IMO this shouldn't be tackled inside the library. In your chatbot, you could create a global intent to detect when a user wants to "abort mission" and go to start again.

siddhant1994 commented 4 years ago

@LordRobert how did you managed to persist slot values when bot asking another questions for me it just keeps on going in loop this is my code am i missing something ?

async function main() {
    const fromEntity = manager.addTrimEntity('fromCity');
    fromEntity.addBetweenCondition('en', 'from', 'to');
    fromEntity.addAfterLastCondition('en', 'from');

    const toEntity = manager.addTrimEntity('toCity');
    toEntity.addBetweenCondition('en', 'to', ['from', 'on']);
    toEntity.addAfterLastCondition('en', 'to');

    manager.slotManager.addSlot('travel', 'toCity', true, {
        en: 'Where do you want to go?'
    });
    manager.slotManager.addSlot('travel', 'date', true, {
        en: 'When do you want to travel?'
    });
    manager.slotManager.addSlot('travel', 'fromCity', true, {
        en: 'From where you are traveling?'
    });

    manager.addDocument('en', 'I want to travel from %fromCity% to %toCity% on %date%', 'travel');
    manager.addDocument('en', 'I am going %toCity% on %date%', 'travel');
    manager.addDocument('en', 'I want to go to %toCity% on %date%', 'travel');
    manager.addDocument('en', 'I want to travel to %toCity%', 'travel');
    manager.addDocument('en', 'Book a flight for %date%', 'travel');
    manager.addDocument('en', 'I want to book flight on  %date%', 'travel');

    manager.addAnswer('en', 'travel', 'I am booking a flight from {{fromCity}} to {{toCity}} on {{date}} for you');

    manager.addAnswer('en', 'None', 'sorry all i can do is book flight');

    await manager.train();
}

and this is part where i ask question

let ask = async (que) => {
    const result = await manager.process('en', que, {});
    return result;
}
Apollon77 commented 2 years ago

My proposal wpuld be to flag the "fallback added entities" with a special flag to be able to detect that the fallback got active here. Then you can use e.g. an action and check the entities and if one entitiy was filled with a fallback value you compare this with a list of "stop words" in cdoe and can cancel the process and return a different answer

aigloss commented 1 year ago

Closing due to inactivity. Please, re-open if you think the topic is still alive.