Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to return Dialog.Delegate directive to Alexa Skill model?

I want to create a simple multi-turn dialog with the Alexa Skill model. My intent consists of 3 slots, each of which are required to fulfill the intent. I prompt every slot and defined all of the needed utterances.

Now I want to handle the request with a Lambda function. This is my function for this specific Intent:

function getData(intentRequest, session, callback) {
    if (intentRequest.dialogState != "COMPLETED"){
        // return a Dialog.Delegate directive with no updatedIntent property.
    } else {
        // do my thing
    }
}

So how would I go on to build my response with the Dialog.Delegate directive, as mentioned in the Alexa documentation?

https://developer.amazon.com/docs/custom-skills/dialog-interface-reference.html#scenario-delegate

Thank you in advance.

like image 648
Ipsider Avatar asked Aug 07 '18 09:08

Ipsider


People also ask

How do you set skill permissions on Alexa?

Open your skill in the developer console. Go to the Build page, and scroll down to Permissions on the lower left. Toggle the permission on for the permission that corresponds to the information your skill requires.

Can we restore our previous version while building Alexa skill?

To roll back to a previously published version of your skillSign in to the ASK developer console. Click the Certification tab and then click the Version History tab. Every time you submit a skill for certification, the submitted version appears in the table displayed on the Version History page.

What is auto delegation in Alexa?

There are two ways to delegate the dialog: Enable auto delegation, either for the entire skill or for specific intents. In this case, Alexa completes all of the dialog steps based on your dialog model. Alexa sends your skill a single IntentRequest when the dialog is complete. Delegate manually with the Dialog.

How do I publish my Alexa custom skill?

Publish a skill that has been certified To publish a skill that is in a Certified status, navigate to Certification > Submission. When publishing your skill, you have the following options: Publish now. Start the process now of publishing the skill to the Alexa Skills Store.


1 Answers

With Dialog.Delegate directive you cannot send outputSpeech or reprompt from your code. Instead those defined in interaction model will be used.

Do not include outputSpeech or reprompt with the Dialog.Directive. Alexa uses the prompts defined in the dialog model to ask the user for the slot values and confirmations.

What this means is that you cannot delegate and provide your own response, but instead you can use any other Dialog directive to provide your outputSpeech and reprompt.

Ex: Dialog.ElicitSlot, Dialog.ConfirmSlot and Dialog.ConfirmIntent.

At any point, you can take over the dialog rather than continuing to delegate to Alexa.

...
    const updatedIntent = handlerInput.requestEnvelope.request.intent;
    if (intentRequest.dialogState != "COMPLETED"){
       return handlerInput.responseBuilder
              .addDelegateDirective(updatedIntent)
              .getResponse();
    } else {
        // Once dialoState is completed, do your thing.
        return handlerInput.responseBuilder
              .speak(speechOutput)
              .reprompt(reprompt)
              .getResponse();
    }
...

The updatedIntent parameter in addDelegateDirective() is optional. It is an intent object representing the intent sent to your skill. You can use this property set or change slot values and confirmation status if necessary.

More on Dialog directives here

like image 157
johndoe Avatar answered Sep 19 '22 13:09

johndoe