How can I navigate users to correct intent based on an input and ask for input for this intent


#1

Hi,
I am requesting for code sample otherwise guidance for the following approach I am taking:

async WelcomeIntent() {
     this.ask('Say contact detail to know about your contact');
},
async UserChoiceIntent() {
    const menu_option = this.$inputs.userchoice.value;
    switch(menu_option){
         case "contact detail":
              return this.toIntent("ContactDetailIntent");
    }
},
async ContactDetailIntent() {
      const emailid = $this.inputs.emailid.value;
      result = async function_name(emailid) {
           ....
      }
}

The objective is to take user’s input and based on that to navigate to another intent with a response about what to do next and alexa would ask for the input inside the navigated intent.

In the above example, what I am trying to accomplish is when user says contact detail it will automatically navigate to ContactDetailIntent and asks user for the input to be used in this intent. But I cannot use response from one intent and navigation to another immediately after this from the same intent. Is this right?

Please help me to know the best way to accomplish this.


#3
Try this;

    async ContactDetailIntent() {
    const emailid = $this.inputs.emailid.value;
    result = await function_name(emailid)
    this.ask(result)
    }

    async function function_name(emailId) {
    return new Promise((resolve, reject) => {
    const options = {
        
    };
    request(options, (error, response, body) => {
           resolve("response")
    });
});

#4

Thank you @florijan.allaraj for your reply. I will try and get back with what I find.


#5

Greetings @emfluenceindia!

I don’t know if i am following correctly but from what i understand, you are trying to manage both actions with one intent. For example, If the user says “contact detail” it will trigger the ContactDetailIntent, and then you want to ask then ask for the input, in this case the email, to then process that input with the same intent (ContactDetailIntent)

If this is the case, I would do the following:
Add utterances for ContactDetailIntent with an without input in your model, meaning both cases it’s supposed to catch. Something like:…

“contact detail”,
“i want the details for {email}”,
…

Then, i would check which case triggered the Intent, if it was without an input (“contact detail”) or if it was with an input(“i want the details for [email protected]”)

I have used something like this for that purpose (maybe there is a better way)

if(this.$inputs.emailid.value === undefined){
     return this.ask("What email should i look for?");
}
else {
    const emailid = $this.inputs.emailid.value;
    result = await function_name(emailid);
    return this.ask(result);
}

Hopefully this helps. Let me know!


#6

Hi @Jesus_Mazzei, it seems to be working now. Thank you so much for your nice idea!

However, I am looking forward to your help for one more time. The user inputs for all my intents are numeric, like 56963201, 45882019 etc. AMAZON.NUMBER is not working from test console and also it is impossible for a user to SAY such long numbers as inputs.

I tried fivesixninesixthreetwozeroone and alexa asked me the same question again (reprompt). I tried by sending it like 59356804 and session ended without any response. I am using alexa test console for this testing. But when I used JOVO debugger, sending the parameter as 59356804 works well.

Ideally, users will input such IDs as digits like by saying fivesixninesixthreetwozeroone. Is there any way I can accomplish this? I am completely clueless! Could not find a solution yet after a lot of googling!

Please suggest.

PS: If you don’t mind, may I send you app.js and en-US.json? If yes, please tell me how.


#7

Hey @emfluenceindia,

I have not worked with this type of slot, but searching on google i found this link - > AMAZON.NUMBER
maybe you could try the inputs that are shown there and get a different result.

Sorry i couldn’t be more helpful.


#8

@Jesus_Mazzei in fact I figured it out. Sending values just like IDs did not work for me but when I added a few words it worked. I don’t know if this is the right way to do it, but at least for me things seem to working OK at the moment! However, since I don’t have a device and my android alexa app is not recognizing the voice (don’t know why) I am not sure yet about how to input a number. Typing the number in alexa test console like I want to know about 59600 is working.