how to create a list of choices with Luis in bot framework sdk (javascript)

Vázquez Romero, Adrián 21 Reputation points
2021-08-25T09:34:55.13+00:00

I'm developing a bot with Azure Bot Framework sdk in javascript.
I have some intents in LUIS in case the user wants to ask a question whenever they want. But I would like the bot to show different choices with this schema:

---select: ['File a complaint', 'Ask a question']

-----(File a complaint)->go here
-----(Ask a question)->['I have not filed the complaint yet', 'I am in the process of filing a complaint', 'I already filed the complaint']

--------(I have not filed the complaint yet)->['how to file a complaint', 'how much does it cost to file a complaint', 'How can I contact you by phone?']
--------(I am in the process of filing a complaint)->['I have problems with the form', 'I want to take up a complaint already started', 'I can not attach a file']
--------(I already filed the complaint)->['I want information about the status of my complaint', 'I want to cancel a complaint already filed']

The problem is that, since I have seen in this Microsoft example I'm using ChoiceFactory.toChoices to prompt the questions, but as I said before, I would like the possibility that the user can ask, for example "I want information about the status of my complaint" at the beggining of the conversation. Now the bot is reprompting the question and do not continue. Also, I want the bot to understand similar sentences using LUIS in the case of ['I have not filed the complaint yet', 'I am in the process of filing a complaint', 'I already filed the complaint']

Here is my code:

class StartMenu extends ComponentDialog {
    constructor(userState) {
        super('userProfileDialog');

        this.userProfile = userState.createProperty(USER_PROFILE);

        this.addDialog(new TextPrompt(NAME_PROMPT));
        this.addDialog(new ChoicePrompt(CHOICE_PROMPT));

        this.addDialog(new WaterfallDialog(WATERFALL_DIALOG, [
            this.firstQuestion.bind(this),
            this.secondQuestion.bind(this),
            this.thirdQuestion.bind(this),
            this.answerTheQuestion.bind(this),
        ]));

        this.initialDialogId = WATERFALL_DIALOG;
    }
    async run(turnContext, accessor) {
        const dialogSet = new DialogSet(accessor);
        dialogSet.add(this);

        const dialogContext = await dialogSet.createContext(turnContext);
        const results = await dialogContext.continueDialog();
        if (results.status === DialogTurnStatus.empty) {
            await dialogContext.beginDialog(this.id);
        }
    }

    async firstQuestion(step) {
        const data = {
            prompt: 'Please, select',
            choices: ChoiceFactory.toChoices(['File a complaint', 'Ask a question'])
        }
        return await step.prompt(CHOICE_PROMPT, data);
    }


    async secondQuestion(step) {
        const response = step.result.value;
        switch (response){
            case 'File a complaint':
                return await step.context.sendActivity(`go to [link](link)`);
            case 'Ask a question':
                const data = {
                    prompt: 'At what point are you?',
                    choices: ChoiceFactory.toChoices(['I have not filed the complaint yet', 'I am in the process of filing a complaint', 'I already filed the complaint'])
                }
                return await step.prompt(CHOICE_PROMPT, data);
        }

    }


    async thirdQuestion(step) {
        const response = step.result.value;
        let data = {}
        switch (response){
            case 'I have not filed the complaint yet':
                data ={
                    prompt: 'What do you need?',
                    choices: ChoiceFactory.toChoices(['how to file a complaint', 'how much does it cost to file a complaint', 'How can I contact you by phone?'])
                }
            case 'I am in the process of filing a complaint':
                data = {
                    prompt: 'What do you need?',
                    choices: ChoiceFactory.toChoices(['I have problems with the form', 'I want to take up a complaint already started', 'I can not attach a file'])
                }
            case 'I already filed the complaint':
                data = {
                    prompt: 'What do you need?',
                    choices: ChoiceFactory.toChoices(['I want information about the status of my complaint', 'I want to cancel a complaint already filed'])
                }
        }

        return await step.prompt(CHOICE_PROMPT, data);

    }
    async answerTheQuestion(step){
        console.log("answerTheQuestion")
    }

What do I have to do to answer final questions with LUIS intent recognition at any point in the flow?
And, to follow the flow using LUIS intents like "ask a question", "I have not filed the complaint yet"... and its variables and show the next choices.
Thanks.

Azure AI Bot Service
Azure AI Bot Service
An Azure service that provides an integrated environment for bot development.
807 questions
{count} votes