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

时间:2018-09-09 03:24:40

标签: alexa alexa-skills-kit alexa-slot

            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);
        
    });
 }
            
            
            

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

请帮助

0 个答案:

没有答案