如何使用数据库值验证Alexa技能中的广告位值

问题描述 投票:1回答:1

            if (!updatedIntent.slots.patient_name.value) 
            {                
                const slotToElicit = 'patient_name';
                const speechOutput = 'What is the patient name ?';
                const repromptSpeech = speechOutput;
                this.emit(':elicitSlot', slotToElicit,speechOutput,repromptSpeech); 
                  
                checkPatientExists(this,updatedIntent);                           
                           
            } 
        
         else if(!updatedIntent.slots.date.value){
                const slotToElicit = 'date';
                const speechOutput = 'When do you want the appointment ?';
                const repromptSpeech = speechOutput;
                this.emit(':elicitSlot', slotToElicit,speechOutput,repromptSpeech);
            }
            
            
            //validating the patient name
            
            function checkPatientExists(inst,updatedIntent){
    var patientName=updatedIntent.slots.patient_name.value;
    pool
    .query({rowsAsArray:true, sql:"select first_name from demographics where first_name='"+patientName+"'"})
    .then(res=>{
         var output=JSON.stringify(res);
         var result=output.substring(3,output.length-3)
         console.log(result);
          if(result.toLowerCase===patientName.toLowerCase){
            inst.response.speak("Your Appointment has been confirmed ")
                           .cardRenderer("patient name: " , result);
                           inst.emit(':responseReady');
          }else{
            inst.response.speak("Patient does not exists")
                          .cardRenderer("patient name: ", patientName);
                          inst.emit(':responseReady');                         
            
          }
    }) 
    .catch(err => {               
        inst.emit(':ask', 'patient name does not exist, please try again');
     console.log("not connected due to error: " + err);
        
    });
 }
            
            
            

我正在尝试使用数据库值验证插槽值,但是在获取第一个插槽的值后,控件始终转到下一个插槽。在要求用户输入第二个插槽之前,如何验证第一个插槽的值?

请帮助

alexa alexa-skills-kit alexa-slot
1个回答
0
投票

您找到解决方案了吗?我遇到了同样的问题

© www.soinside.com 2019 - 2024. All rights reserved.