在alexa自托管中如何解决这个问题?

如何解决在alexa自托管中如何解决这个问题?

我有这个问题,总是感到抱歉,我有困难。我有图片和下面的代码。 出于某种原因,我不知道问题是什么,但是当我检查登录云手表时。它给了我这个错误处理:{} enter image description here

这个代码文件,不用担心常量,因为它没有任何问题

/* *
 * This sample demonstrates handling intents from an Alexa skill using the Alexa Skills Kit SDK (v2).
 * Please visit https://alexa.design/cookbook for additional examples on implementing slots,dialog management,* session persistence,api calls,and more.
 * */
const Alexa = require('ask-sdk-core');
const msg = require("./localisation");
const constants = require("./constants");

const getSlotValues = (handlerInput) => {
    return handlerInput.requestEnvelope.request.intent.slots;
}

const LaunchRequestHandler = {
    canHandle(handlerInput) {
        return Alexa.getRequestType(handlerInput.requestEnvelope) === 'LaunchRequest';
    },handle(handlerInput) {
        const speakOutput = msg.HELLO_MSG;

        return handlerInput.responseBuilder
            .speak(speakOutput)
            .reprompt(speakOutput)
            .getResponse();
    }
};
//If user the say follow up,we are going to ask another question.
const FollowUpIntentHandler = {
    canHandle(handlerInput) {
        return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
            && Alexa.getIntentName(handlerInput.requestEnvelope) === 'FollowUpIntentHandler';
    },handle(handlerInput) {
        const {responseBuilder,attributesManager} = handlerInput;
        const slotValue = getSlotValues(handlerInput);
        const sessionAttribute = attributesManager.getSessionAttributes();
        sessionAttribute['follow']= slotValue.follow.value;
        // const sessionAttribute = attributeManager.getSessionAttributes();
        // const slotValues = getSlotValues(handlerInput);

        // sessionAttribute["follow"] = slotValues.follow.value;

        const speakOutput = msg.FOLLOW_UP_QUESTION_MSG;
        return responseBuilder
            .speak(speakOutput)
            .reprompt('add a reprompt if you want to keep the session open for the user to respond')
            .getResponse();
    }
};
//If user the say new we are going to ask another question.
const NewIntentHandler = {
    canHandle(handlerInput){
        const {request} = handlerInput.requestEnvelope;
        return request.type === 'IntentRequest'
            && request.intent.name === "NewIntentHandler";
    },handle(handlerInput){
        const {responseBuilder,attributeManager} = handlerInput;
        const sessionAttribute = attributeManager.getSessionAttributes();
        const slotValues = getSlotValues(handlerInput);

        sessionAttribute["new"] = slotValues.new.value;
        
        const speakOutput = msg.NEW_QUESTION_MSG;
     
        return responseBuilder.speak(speakOutput).reprompt(speakOutput).getResponse();

    }   
};
const CaptureUserQuestionIntentHandler = {
    canHandle(handlerInput){
        const {request} = handlerInput.requestEnvelope;
        const {attributesManager} = handlerInput;
        const sessionAttribute = attributesManager.getSessionAttributes();

        return request.type === "IntentRequest"
            && request.intent.name === "CaptureUserQuestionIntentHandler"
            || sessionAttribute['new']
            || sessionAttribute['follow'];
    },handle(handlerInput){
       const slotValue = getSlotValues(handlerInput);
       const {responseBuilder,attributesManager} = handlerInput;
       const sessionAttribute = attributesManager.getSessionAttributes();
       
       sessionAttribute["bodyPart"] = slotValue.bodyPart.value;
       sessionAttribute["drainage"] = slotValue.drainage.value;
       sessionAttribute["time"] = slotValue.time.value;
       
    //   const bodyPart = slotValue.bodyPart.value;
    //   const time = slotValue.time.value;
    //   const drainage = slotValue.drainage.value;

       const speakOutput = `What is the ${sessionAttribute['drainage']} coming from? The back of the ear near the incision or the opening of your ear or ear canal?`;
       
       return responseBuilder
            .speak(speakOutput)
            .reprompt(speakOutput)
            .getResponse()

    }
};

const BackOrNearIncisionIntentHandler = {
    canHandle(handlerInput){
        const {request} = handlerInput.requestEnvelope;
        const {attributesManager} =  handlerInput;
        const sessionAttribute = attributesManager.getSessionAttributes();
        
        return request.type === "IntentRequest"
            && request.intent.name === "BackOrNearIncisionIntentHandler"
            && sessionAttribute["drainage"];
    },handle(handlerInput){
        const slotValues = getSlotValues(handlerInput);
        const {attributesManager,responseBuilder} = handlerInput;
        const sessionAttribute = attributesManager.getSessionAttributes();
        
        let speakOutput;
        
        sessionAttribute['color'] = slotValues.color.value;
        const color = sessionAttribute['color'];
        
        if(color === constants.CLEAR){
            speakOutput = msg.IMPORANT_GET_TREATED; 
        }else{
             speakOutput = msg.SUGGEST_APPLY_MEDICINE;
        }
       
        return responseBuilder
            .speak(speakOutput)
            .reprompt(speakOutput)
            .getResponse()
        
    }
};

const YesPleaseIntentHandler = {
    canHandle(handlerInput){
        const {request} = handlerInput.requestEnvelope;
        const {attributesManager} = handlerInput;
        const sessionAttribute = attributesManager.getSessionAttributes();
        
        
        return request.type === "IntentRequest"
            && request.intent.name === "AMAZON.YesIntent"
            && sessionAttribute["color"] === constants.CLEAR;
    },handle(handlerInput){
        const {responseBuilder} = handlerInput;
        // let speakOutput = msg.YOUR_NEXT_APPOINTMENT;
        let speakOutput = msg.YOUR_NEXT_APPOINTMENT;
        
        return responseBuilder
            .speak(speakOutput)
            .reprompt(speakOutput)
            .getResponse()
    }
};

const RegisterBirthdayIntentHandler = {
    canHandle(handlerInput){
        const {request} = handlerInput.requestEnvelope;
        
        return request.type === "IntentRequest" && request.intent.name === "CaptureRegisterBirthdayIntent";
    },handle(handlerInput){
        const {responseBuilder} = handlerInput;
        let speakOutput = "please work";
         console.log(RegisterBirthdayIntentHandler);
        console.log(handlerInput);
        return responseBuilder
            .speak(speakOutput)
            .reprompt(speakOutput)
            .getResponse()
    }
};

const HelpIntentHandler = {
    canHandle(handlerInput) {
        return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
            && Alexa.getIntentName(handlerInput.requestEnvelope) === 'AMAZON.HelpIntent';
    },handle(handlerInput) {
        const speakOutput = 'You can say hello to me! How can I help?';

        return handlerInput.responseBuilder
            .speak(speakOutput)
            .reprompt(speakOutput)
            .getResponse();
    }
};

const CancelAndStopIntentHandler = {
    canHandle(handlerInput) {
        return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
            && (Alexa.getIntentName(handlerInput.requestEnvelope) === 'AMAZON.CancelIntent'
                || Alexa.getIntentName(handlerInput.requestEnvelope) === 'AMAZON.StopIntent');
    },handle(handlerInput) {
        const speakOutput = 'Goodbye!';

        return handlerInput.responseBuilder
            .speak(speakOutput)
            .getResponse();
    }
};
/* *
 * FallbackIntent triggers when a customer says something that doesn’t map to any intents in your skill
 * It must also be defined in the language model (if the locale supports it)
 * This handler can be safely added but will be ingnored in locales that do not support it yet 
 * */
const FallbackIntentHandler = {
    canHandle(handlerInput) {
        return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
            && Alexa.getIntentName(handlerInput.requestEnvelope) === 'AMAZON.FallbackIntent';
    },handle(handlerInput) {
        const speakOutput = 'Sorry,I don\'t kNow about that. Please try again.';

        return handlerInput.responseBuilder
            .speak(speakOutput)
            .reprompt(speakOutput)
            .getResponse();
    }
};
/* *
 * SessionEndedRequest notifies that a session was ended. This handler will be triggered when a currently open 
 * session is closed for one of the following reasons: 1) The user says "exit" or "quit". 2) The user does not 
 * respond or says something that does not match an intent defined in your voice model. 3) An error occurs 
 * */
const SessionEndedRequestHandler = {
    canHandle(handlerInput) {
        return Alexa.getRequestType(handlerInput.requestEnvelope) === 'SessionEndedRequest';
    },handle(handlerInput) {
        console.log(`~~~~ Session ended: ${JSON.stringify(handlerInput.requestEnvelope)}`);
        // Any cleanup logic goes here.
        return handlerInput.responseBuilder.getResponse(); // notice we send an empty response
    }
};
/* *
 * The intent reflector is used for interaction model testing and debugging.
 * It will simply repeat the intent the user said. You can create custom handlers for your intents 
 * by defining them above,then also adding them to the request handler chain below 
 * */
const IntentReflectorHandler = {
    canHandle(handlerInput) {
        return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest';
    },handle(handlerInput) {
        const intentName = Alexa.getIntentName(handlerInput.requestEnvelope);
        const speakOutput = `You just triggered ${intentName}`;

        return handlerInput.responseBuilder
            .speak(speakOutput)
            //.reprompt('add a reprompt if you want to keep the session open for the user to respond')
            .getResponse();
    }
};
/**
 * Generic error handling to capture any Syntax or routing errors. If you receive an error
 * stating the request handler chain is not found,you have not implemented a handler for
 * the intent being invoked or included it in the skill builder below 
 * */
const ErrorHandler = {
    canHandle() {
        return true;
    },handle(handlerInput,error) {
        const speakOutput = 'Sorry,I had trouble doing what you asked. Please try again.';
        console.log(`~~~~ Error handled: ${JSON.stringify(error)}`);

        return handlerInput.responseBuilder
            .speak(speakOutput)
            .reprompt(speakOutput)
            .getResponse();
    }
};

/**
 * This handler acts as the entry point for your skill,routing all request and response
 * payloads to the handlers above. Make sure any new handlers or interceptors you've
 * defined are included below. The order matters - they're processed top to bottom 
 * */
exports.handler = Alexa.SkillBuilders.custom()
    .addRequestHandlers(
        LaunchRequestHandler,YesPleaseIntentHandler,FollowUpIntentHandler,BackOrNearIncisionIntentHandler,NewIntentHandler,CaptureUserQuestionIntentHandler,RegisterBirthdayIntentHandler,HelpIntentHandler,CancelAndStopIntentHandler,FallbackIntentHandler,SessionEndedRequestHandler,IntentReflectorHandler)
    .addErrorHandlers(
        ErrorHandler)
    .withCustomUserAgent('sample/hello-world/v1.2')
    .lambda();

这是技能的json编辑器

{
    "interactionModel": {
        "languageModel": {
            "invocationName": "lee healthcare","intents": [
                {
                    "name": "AMAZON.CancelIntent","samples": []
                },{
                    "name": "AMAZON.HelpIntent",{
                    "name": "AMAZON.StopIntent",{
                    "name": "AMAZON.NavigateHomeIntent",{
                    "name": "AMAZON.FallbackIntent",{
                    "name": "FollowUpIntentHandler","slots": [
                        {
                            "name": "follow","type": "FOLLOW"
                        }
                    ],"samples": [
                        "{follow} up question","{follow} up","{follow}"
                    ]
                },{
                    "name": "NewIntentHandler","slots": [
                        {
                            "name": "new","type": "NEW"
                        }
                    ],"samples": [
                        "{new} question","{new}"
                    ]
                },{
                    "name": "CaptureUserQuestionIntentHandler","slots": [
                        {
                            "name": "bodyPart","type": "BODYPARTS"
                        },{
                            "name": "time","type": "customDate","samples": [
                                "{time}"
                            ]
                        },{
                            "name": "drainage","type": "DRAIN","samples": [
                                "{drainage}"
                            ]
                        }
                    ],"samples": [
                        "I have {bodyPart} surgery {time} and have {drainage}"
                    ]
                },{
                    "name": "BackOrNearIncisionIntentHandler","slots": [
                        {
                            "name": "color","type": "AMAZON.Color","samples": [
                                "{color}"
                            ]
                        }
                    ],"samples": [
                        "{color}","near the incision","back of the ear near the incision"
                    ]
                },{
                    "name": "AMAZON.YesIntent",{
                    "name": "CaptureRegisterBirthdayIntent","slots": [
                        {
                            "name": "name","type": "Name"
                        }
                    ],"samples": [
                        "my name is {name}"
                    ]
                }
            ],"types": [
                {
                    "name": "FOLLOW","values": [
                        {
                            "name": {
                                "value": "follow"
                            }
                        }
                    ]
                },{
                    "name": "NEW","values": [
                        {
                            "name": {
                                "value": "new"
                            }
                        }
                    ]
                },{
                    "name": "BODYPARTS","values": [
                        {
                            "name": {
                                "value": "ear"
                            }
                        }
                    ]
                },{
                    "name": "DRAIN","values": [
                        {
                            "name": {
                                "value": "drainage"
                            }
                        }
                    ]
                },{
                    "name": "customDate","values": [
                        {
                            "name": {
                                "value": "last week"
                            }
                        }
                    ]
                },{
                    "name": "YESSLOT","values": [
                        {
                            "name": {
                                "value": "yes please"
                            }
                        },{
                            "name": {
                                "value": "yes"
                            }
                        }
                    ]
                },{
                    "name": "Name","values": [
                        {
                            "name": {
                                "value": "John"
                            }
                        }
                    ]
                }
            ]
        },"dialog": {
            "intents": [
                {
                    "name": "CaptureUserQuestionIntentHandler","confirmationrequired": false,"prompts": {},"type": "BODYPARTS","elicitationrequired": false,"prompts": {}
                        },"elicitationrequired": true,"prompts": {
                                "elicitation": "Elicit.Slot.832794320406.761354353518"
                            }
                        },"prompts": {
                                "elicitation": "Elicit.Slot.832794320406.873931110175"
                            }
                        }
                    ]
                },"prompts": {
                                "elicitation": "Elicit.Slot.414884367204.126479337664"
                            }
                        }
                    ]
                }
            ],"delegationStrategy": "ALWAYS"
        },"prompts": [
            {
                "id": "Slot.Validation.544061479456.1369268390684.618525999294","variations": [
                    {
                        "type": "PlainText","value": "Can i help you with the follow question or new question?"
                    }
                ]
            },{
                "id": "Elicit.Slot.832794320406.761354353518","value": "When does it happen?"
                    }
                ]
            },{
                "id": "Elicit.Slot.832794320406.873931110175","value": "What else do you have ?"
                    }
                ]
            },{
                "id": "Elicit.Slot.414884367204.126479337664","value": "What color is drainage?"
                    }
                ]
            }
        ]
    }
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?