3
votes

I'm trying to build a custom Alexa skill for a gratitude diary. The goal is to have an interaction in which the Alexa device asks the user what they're grateful for, and repeats it back as confirmation.

I'm encountering a problem when it comes to repeating back what the user has said. I'd like the conversation to go like this:

Alexa: What are you grateful for today?
User I'm grateful for dogs
Alexa: You said you're grateful for dogs. Is that correct?

I've set this up as a single intent, as follows:

  • gratitude_object as a required slot, of type AMAZON.SearchQuery
  • user utterances for this slot are I'm grateful for {gratitude_object} (and a few variations)
  • confirmation message for this slot is You're feeling grateful for {gratitude_object}. Is that correct?

The problem I'm encountering is that when I test this model in the Utterance Profiler, it goes like this:

Alexa: What are you grateful for today?
User I'm grateful for dogs
Alexa: You said you're grateful for I'm grateful for dogs. Is that correct?

I'm guessing this is something to do with the fact that AMAZON.SearchQuery will accept anything as valid input, but I'm not sure how to go about resolving this.

I've also tried creating a custom slot for the I'm grateful for phrase:

  • slot name: gratitude_phrase_initiator
  • slot type: custom slot type
  • slot values: "I'm grateful for", "I am grateful for" (etc)

However, if I then try to use this slot in my intent, by making the user utterance for the gratitude_object slot:

{gratitude_phrase_initiator} {gratitude_object}

...then I get the following error:

Sample utterance "{gratitude_statement_initiator} {gratitude_object}" for slot "gratitude_object" in intent "NewEntryIntent" cannot include both a phrase slot and another intent slot. Error code: InvalidSlotSamplePhraseSlot

.

I'd really like to keep the interaction as it is currently, with the user starting by saying "I'm grateful for...". Any suggestions for how I could make this work using the interaction model, or is it just impossible? Is this something I could handle in the code instead of the interaction model?

1
Very well written question! Looks like you set it up perfectly but you would expect SearchQuery to do a better job of excluding the initial utterance phrase. So you'll have to parse it some more in code. You should use a Lambda Function to string replace the slot value to remove any initiator phrases.Jay A. Little
Thanks @JayA.Little! If you'd like to make this comment an answer, I'll accept it.ldbrooke

1 Answers

0
votes

Looks like you set it up perfectly but you would expect SearchQuery to do a better job of excluding the initial utterance phrase. So you'll have to parse it some more in code. You should use a Lambda Function to string replace the slot value to remove any initial phrases.

Example in Node.js:

var gratitude_object = this.event.request.intent.slots.gratitude_object.value;

var initial_phrases = [
    "i'm grateful for",
    "i am grateful for",
];

initial_phrases.forEach(function(value){
    gratitude_object = gratitude_object.toLowerCase().replace(value,"");
});

Notice the array of intitial phrases are written in lowercase and the forEach loop also makes the slot value lowercase before checking to replace. That way you don't have to worry about case matching when writing the initial phrases you want to remove.