Complete dialogtest

This commit is contained in:
GotPPay
2018-01-19 08:00:51 +01:00
parent b07a9e21b3
commit 4b594898b1

View File

@@ -55,9 +55,55 @@ module.exports = {
//Handler for sending message
handlers.SendMessageIntent = function () {
console.log("Dialog state : " + this.event.request.dialogState);
console.log("Intent object :");
console.log(this.event.request.intent);
let intent = this.event.request.intent;
console.log ('Dialog state : ' + this.event.request.dialogState);
console.log ('Intent object :');
console.log (intent);
if (this.event.request.dialogState === 'STARTED') {
//Should this be in constants ?
if (!intent.slots.Name.value) {
//Name not defined yet, ask user for name
const slotToElicit = 'Name';
const speechOutput = 'What is your name';
const repromptSpeech = speechOutput;
this.emit (
':elicitSlot',
slotToElicit,
speechOutput,
repromptSpeech
);
} else if (!intent.slots.Email.value) {
//Name not defined yet, ask user for email
const slotToElicit = 'Email';
const speechOutput = 'What is your email';
const repromptSpeech = speechOutput;
this.emit (
':elicitSlot',
slotToElicit,
speechOutput,
repromptSpeech
);
} else if (!intent.slots.Message.value) {
const slotToElicit = 'Message';
const speechOutput = 'What is your message';
const repromptSpeech = speechOutput;
this.emit (
':elicitSlot',
slotToElicit,
speechOutput,
repromptSpeech
);
} else {
//all slots are filled
console.log ('Name : ' + intent.slots.Name.value);
console.log ('Email : ' + intent.slots.Email.value);
console.log ('Message : ' + intents.slots.Message.value);
this.response.speak ('Ok. Someone will contact you ASAP');
this.emit (':responseReady');
}
}
};
//Default handlers for unknown questions and session close