0
votes

I want to accomplish the following scenario: A small dialog between Alexa and the user, with the following 2 Intents:

  • NameIntent: "My name is {name}"

Where {name} is AMAZON.US_FIRST_NAME and with the slot made required and a prompt defined.

  • ActivityIntent: "I like {activity}"

And here it becomes more difficult. I made {activity} a custom slot and defined some values for it like "fishing, sports" and the like, but obviously there are more answers to this. If I now respond with something I don't have defined (e.g. "darts"), Alexa always goes back to the first intent, as it seems to thing it is a name.

Example:

LaunchRequest: "Welcome. What is your name?" -> My name is Peter

NameIntent: "Welcome Peter. What do you like to do?" -> Darts -> "Welcome Darts. What do you like to do?"

I would simply like to have Alexa accept whatever value the user says there, in Dialogflow this would be simply done with an {any} entity. I followed this blog article from the alexa blog, and there they seem to be able to capture whatever nickname you throw at it, even ones which aren't defined, which is what I want to accomplish here.

Question: How can I capture any kind of input with Alexa, phrases beyond whatever I have defined in the skill builder? How can I make sure this phrase gets directed to the correct intent?

I am a bit frustrated with this, especially if you use ElicitSlotDirectives to specifically ask the user about a slot, and then it jumps to a completely different intent.

The code for the 2 intent handlers:

const NameIntentHandler = {
    canHandle(handlerInput) {
        return handlerInput.requestEnvelope.request.type === 'IntentRequest'
            && handlerInput.requestEnvelope.request.intent.name === 'NameIntent';
    },
    handle(handlerInput) {
        const { intent } = handlerInput.requestEnvelope.request;
        const name = intent.slots.name.value;

        const speechText = `Welcome ${name}. What is your favourite activity?`;
        return handlerInput.responseBuilder
            .speak(speechText)
            .reprompt(speechText)
            .withShouldEndSession(false)
            .getResponse();
    },
};

const ActivityIntentHandler = {
    canHandle(handlerInput) {
        return handlerInput.requestEnvelope.request.type === 'IntentRequest'
            && handlerInput.requestEnvelope.request.intent.name === 'ActivityIntent';
    },
    handle(handlerInput) {
        const { intent } = handlerInput.requestEnvelope.request;
        const activity = intent.slots.activity.value;

        const speechText = `You like ${activity}.`;
        return handlerInput.responseBuilder
            .speak(speechText)
            .reprompt(speechText)
            .withShouldEndSession(false)
            .getResponse();
    },
};
2

2 Answers

0
votes

It seems that Alexa is having trouble associating activity utterances with your ActivityIntent and instead is invoking the NameIntent again. Relying on Amazon to figure out which intent to use based on slot type has not consistently worked well for me. If you post your intent code that would be very helpful.

It may help to look at a JavaScript example from Amazon here and Amazon's Voice Design Guide.

0
votes

You might consider using AMAZON.LITERAL built-in custom slot type. This slot type passes the spoken words without any conversion. Although official documents suggest against using it. It was also discontinued once. From the official docs.

Note: Although you can submit new and updated English (US) skills with AMAZON.LITERAL, custom slot types provide better accuracy than AMAZON.LITERAL in most cases. Therefore, we recommend that you consider migrating to custom slot types if possible. Note that AMAZON.LITERAL is not supported for any language other than English (US).

Find more about AMAZON.LITERAL here. https://developer.amazon.com/docs/custom-skills/literal-slot-type-reference.html