code fix and improvements

This commit is contained in:
GotPPay
2018-01-19 20:23:50 +01:00
parent 434d45248c
commit b73086291c
3 changed files with 49 additions and 35 deletions

View File

@@ -88,12 +88,10 @@ module.exports = {
repromptSpeech
);
} else if (!intent.slots.Message.value) {
intent.slots.Email.value = emailHelper.transformEmailFromAlexaResponse(intent.slots.Email.value);
if (
!emailHelper.isEmailValid (
intent.slots.Email.value
)
) {
intent.slots.Email.value = emailHelper.transformEmailFromAlexaResponse (
intent.slots.Email.value
);
if (!emailHelper.isEmailValid (intent.slots.Email.value)) {
//Email is not valid, ask again
const slotToElicit = 'Email';
const speechOutput =
@@ -103,7 +101,8 @@ module.exports = {
':elicitSlot',
slotToElicit,
speechOutput,
repromptSpeech
repromptSpeech,
intent
);
} else {
//Email is valid
@@ -122,24 +121,27 @@ module.exports = {
console.log ('Name : ' + intent.slots.Name.value);
console.log ('Email : ' + intent.slots.Email.value);
console.log ('Message : ' + intent.slots.Message.value);
emailHelper.sendEmal (
intent.slots.Name.value,
intent.slots.Email.value,
intent.slots.Message.value,
destinationEmail
).then(info=>{
console.log(info);
this.response.speak (
'Ok. Message sent. Someone will contact you ASAP'
);
this.emit (':responseReady');
}).catch(error=>{
console.log(error);
this.response.speak (
'Sorry, there was a problem with sending message.'
);
this.emit (':responseReady');
});
emailHelper
.sendEmal (
intent.slots.Name.value,
intent.slots.Email.value,
intent.slots.Message.value,
destinationEmail
)
.then (info => {
console.log (info);
this.response.speak (
'Ok. Message sent. Someone will contact you ASAP'
);
this.emit (':responseReady');
})
.catch (error => {
console.log (error);
this.response.speak (
'Sorry, there was a problem with sending message.'
);
this.emit (':responseReady');
});
}
};