Complete dialogtest
This commit is contained in:
@@ -55,9 +55,55 @@ module.exports = {
|
|||||||
|
|
||||||
//Handler for sending message
|
//Handler for sending message
|
||||||
handlers.SendMessageIntent = function () {
|
handlers.SendMessageIntent = function () {
|
||||||
console.log("Dialog state : " + this.event.request.dialogState);
|
let intent = this.event.request.intent;
|
||||||
console.log("Intent object :");
|
|
||||||
console.log(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
|
//Default handlers for unknown questions and session close
|
||||||
|
|||||||
Reference in New Issue
Block a user