question

vishnu kausik avatar image
vishnu kausik asked

How to send the data alexa returns to an APL checklist???

I am making a small Recipe skill as a personal hobby and I am kinda stuck at a place.

This is what I have:

const SpecialRecipeIntentHandler = {
    canHandle(handlerInput) {
        return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
            && Alexa.getIntentName(handlerInput.requestEnvelope) === 'SpecialRecipeIntent';
    },
    async handle(handlerInput) {
        let outputSpeech = 'This is the default message.';
        const Dish = Alexa.getSlotValue(handlerInput.requestEnvelope, 'DishType') 
        const Meal = Alexa.getSlotValue(handlerInput.requestEnvelope, 'MealType') 
        const Diet = Alexa.getSlotValue(handlerInput.requestEnvelope, 'DietType') 
        const Health = Alexa.getSlotValue(handlerInput.requestEnvelope, 'HealthType') 
        const Cuisine = Alexa.getSlotValue(handlerInput.requestEnvelope, 'CuisineType') 
        const Food = Alexa.getSlotValue(handlerInput.requestEnvelope, 'FoodType')
        const Exclusions = Alexa.getSlotValue(handlerInput.requestEnvelope, 'exclusions')

const data = await getRemoteData(`https://api.edamam.com/api/recipes/v2?type=public&q=${Food}&app_id=xxxxx&app_key=xxxxxx&diet=${Health}&health=${Diet}&cuisineType=${Cuisine}&mealType=${Meal}&dishType=${Dish}&calories=200-600&time=20-40&imageSize=REGULAR&excluded=${Exclusions}`).then(JSON.parse);

outputSpeech = `The ingridents required are, `;
for (let i = 0; i < data.hits[0].recipe.ingredients.length; i += 1) {
          if (i === 0) {
            // first record
            outputSpeech = `${outputSpeech} ${data.hits[0].recipe.ingredients[i].text}, `;
          } else if (i === data.hits[0].recipe.ingredients.length - 1) {
            // last record
            outputSpeech = `${outputSpeech} and ${data.hits[0].recipe.ingredients[i].text}. `;
          } else {
            // middle record(s)
            outputSpeech = ` ${outputSpeech + data.hits[0].recipe.ingredients[i].text},`;
          }
if (aplHelper.supportsAPL(handlerInput)) {
  handlerInput.responseBuilder.addDirective({
    type: 'Alexa.Presentation.APL.RenderDocument',
    token: 'ImageToken',    
    document: require('./apl/layouts/Recipe.json'),
    datasources: {
      Recipe: {
        type: 'object',
        properties: {
          APL1: outputSpeech

        }
      }
    }
  });
}
    
}
return handlerInput.responseBuilder.speak(outputSpeech).getResponse();
}
}

//The above cod lists out all the required Ingrediants, which in my case is:
"1 pound spaghetti noodles, or pasta",
          "4 -6 tablespoons butter",
          "1/2-3/4 cups grated parmesan cheese",
          "1 -2 teaspoons ground pepper",
          "4-6 quarts boiling water",
          "dash salt"


This is the checklist APL that Amazon has already provided:
{
    "type": "APL",
    "version": "1.7",
    "license": "Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.\nSPDX-License-Identifier: LicenseRef-.amazon.com.-AmznSL-1.0\nLicensed under the Amazon Software License  http://aws.amazon.com/asl/",
    "import": [
        {
            "name": "alexa-layouts",
            "version": "1.4.0"
        }
    ],
    "mainTemplate": {
        "item": [
            {
                "type": "Container",
                "width": "100%",
                "height": "100%",
                "items": [
                    {
                        "type": "Container",
                        "items": [
                            {
                                "type": "AlexaBackground",
                                "backgroundImageSource": "https://d2o906d8ln7ui1.cloudfront.net/images/templates_v3/textlist/AlexaTextListBackground_Dark.png",
                                "backgroundBlur": false,
                                "backgroundScale": "best-fill"
                            },
                            {
                                "type": "Container",
                                "height": "100vh",
                                "width": "100vw",
                                "items": [
                                    {
                                        "type": "AlexaHeader",
                                        "headerTitle": "Ingridents",
                                        "headerBackButton": false
                                    },
                                    {
                                        "type": "AlexaCheckbox",
                                        "id": "checkbox_global",
                                        "position": "absolute",
                                        "right": "@marginHorizontal",
                                        "top": "15dp",
                                        "isIndeterminate": true,
                                        "primaryAction": [
                                            {
                                                "type": "SetValue",
                                                "componentId": "checkbox_1",
                                                "property": "checked",
                                                "value": "${event.source.checked}"
                                            },
                                            {
                                                "type": "SetValue",
                                                "componentId": "checkbox_2",
                                                "property": "checked",
                                                "value": "${event.source.checked}"
                                            },
                                            {
                                                "type": "SetValue",
                                                "componentId": "checkbox_3",
                                                "property": "checked",
                                                "value": "${event.source.checked}"
                                            },
                                            {
                                                "type": "SetValue",
                                                "componentId": "checkbox_4",
                                                "property": "checked",
                                                "value": "${event.source.checked}"
                                            }
                                        ]
                                    },
                                    {
                                        "type": "Container",
                                        "numbered": true,
                                        "data": [
                                            {
                                                "name": "Recipes"
                                            }
                                                
                                            
                                            
                                        ],
                                        "items": [
                                            {
                                                "type": "Container",
                                                "direction": "row",
                                                "items": [
                                                    {
                                                        "type": "AlexaTextListItem",
                                                        "primaryText": "${data.name}",
                                                        "touchForward": true,
                                                        "hideOrdinal": true
                                                    },
                                                    {
                                                        "type": "AlexaCheckbox",
                                                        "id": "checkbox_${ordinal}",
                                                        "checked": "${data.checked}",
                                                        "position": "absolute",
                                                        "right": "@marginHorizontal",
                                                        "top": "15dp",
                                                        "primaryAction": [
                                                            {
                                                                "when": "${!event.source.check}",
                                                                "type": "SetValue",
                                                                "componentId": "checkbox_global",
                                                                "property": "isIndeterminate",
                                                                "value": true
                                                            },
                                                            {
                                                                "when": "${!event.source.check}",
                                                                "type": "SetValue",
                                                                "componentId": "checkbox_global",
                                                                "property": "checked",
                                                                "value": false
                                                            }
                                                        ]
                                                    }
                                                ]
                                            }
                                        ]
                                    }
                                ]
                            }
                        ]
                    }
                ]
            }
        ]
    }
}

How do I get the list of ingridents to show up on an Echo Show as a check list, How do I  transfer that data from what alexa gives to the Echo show?!??!

I just started developing skills for my echo devices, been scratching my head for the past few days. hoping to solve this soon!!

Regards


alexa skills kitalexaecho showapl
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

KirkC@Amazon avatar image
KirkC@Amazon answered

Hi. It looks like you reached out to us directly using our Contact Us channel as well and that you should have now received a response with some guidance.

We hope that that information helps, if further guidance is needed, please feel free to reply to us directly via the link at the bottom of our most recent e-mail correspondence.

10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.