question

VzquezRomeroAdrin-8841 avatar image
0 Votes"
VzquezRomeroAdrin-8841 asked romungi-MSFT commented

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

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-bot-service
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@VzquezRomeroAdrin-8841 If you would like to use LUIS then a LUIS app should first be created to define a set of utterances, entities and intents. Once this is identified and a app is trained LUIS does most of the heavy lifting identifying similar questions asked by users and returns the top intent. In your case it could be filing a complaint, lookup a complaint or cancel a complaint.

Based on the LUIS intent that is returned your bot can check if valid entities are returned and the next step could be to file a complaint, lookup a complaint or cancel a complaint. I would recommend to go through this sample in the documentation on how to integrate LUIS in your bot. With the sample you mentioned you can build a workflow but integrating LUIS would need an app to be tested from LUIS portal first and then the integration with bot framework would be easier to achieve.


0 Votes 0 ·

0 Answers