change utterances to correct form;change intents to mimic dialog;
This commit is contained in:
@@ -92,25 +92,27 @@ var updateIntentsJSON = function () {
|
||||
//This is problem only if we introduce slot options for regular intents for users
|
||||
alexaApp.intent('EmailIntent',{
|
||||
slots:{
|
||||
'Name':'AMAZON.Person',
|
||||
'Name':'AMAZON.US_FIRST_NAME',
|
||||
'Email' : 'AMAZON.LITERAL',
|
||||
'Message': 'AMAZON.LITERAL',
|
||||
'Data': 'AMAZON.LITERAL'
|
||||
},
|
||||
utterances: [
|
||||
'My name is {Name}',
|
||||
'I am {Name}',
|
||||
'{Data}',
|
||||
'My email is {Email}',
|
||||
'Send replay to {Email}',
|
||||
'My message is {Message}'
|
||||
'My name is {-|Name}',
|
||||
'I am {-|Name}',
|
||||
'{dawdw at dwd wdw|Data}',
|
||||
'My email is {wadwwdw at wadwwd wdw|Email}',
|
||||
'Send replay to {fkofkeofe at dppfam wd|Email}',
|
||||
'My message is {Quick brown fox jumps over lazy dog|Message}'
|
||||
]
|
||||
},
|
||||
function(request,response){
|
||||
if (!Name) Name = response.slots['Name'];
|
||||
if (!Email) Email = response.slots['Email'];
|
||||
if (!Message) Message = response.slots['Message'];
|
||||
let Data = reponse.slots['Data'];
|
||||
let Data = undefined;
|
||||
try{if (!Name) Name = request.slot('Name');}catch(e){console.log('Error. No name slot ');Name=undefined;}
|
||||
try{if (!Email) Email = request.slot('Email');}catch(e){console.log('Error. No Email slot');Email=undefined;}
|
||||
try{if (!Message) Message = request.slot('Message');}catch(e){console.log('Error. No Message slot');Message=undefined;}
|
||||
try{Data = request.slot('Data');}catch(e){console.log('Error. No Data slot');Data=undefined;}
|
||||
console.log('State : ' + State);
|
||||
|
||||
//TODO : Responses could be configurable for each skill ?
|
||||
|
||||
@@ -118,6 +120,7 @@ var updateIntentsJSON = function () {
|
||||
//Was waiting for name, so if Name is null, name is probably in Data
|
||||
if ((!Name && Data) || Name){
|
||||
//got the name, let's continue for the email
|
||||
if (!Name) Name = Data;
|
||||
State = 2;
|
||||
return response.say('Ok ' + Name + '. What is your email ?').shouldEndSession(false);
|
||||
}else{
|
||||
@@ -128,7 +131,7 @@ var updateIntentsJSON = function () {
|
||||
//was waiting for email, so if Email is null, email is probably in Data
|
||||
if ((!Email && Data) || Email){
|
||||
//Got the email, first verify email and than continue to message
|
||||
|
||||
if (!Email) Email = Data;
|
||||
//TODO : verify email
|
||||
State = 3;
|
||||
return response.say('Great. Whats the message ?').shouldEndSession(false);
|
||||
@@ -140,11 +143,18 @@ var updateIntentsJSON = function () {
|
||||
//Was waiting for message, so if Message is null, message is probably in Data
|
||||
if ((!Message && Data) || Message){
|
||||
//Ok, we got all informations. Exit email intent
|
||||
if (!Message) Message=Data;
|
||||
State = 0;
|
||||
//TODO : Send email
|
||||
console.log('Name : ' + Name + ' | Email : ' + Email + ' | Message : ' + Message);
|
||||
return response.say('Message sent. Someone will contact you ASAP');
|
||||
}
|
||||
}
|
||||
}else{
|
||||
//Something is wrong, ask for the message again
|
||||
return response.say('Sorry, I didnt understand your message. Can you say it again ?').shouldEndSession(false);
|
||||
}
|
||||
}else{
|
||||
console.log('State strange ! ' + State);
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
@@ -197,6 +207,7 @@ router.post ('/updateSkill/:id', async (req, res, next) => {
|
||||
if (id !== '-1') {
|
||||
if (updateOnAmazon){
|
||||
amazonHelper.updateSkill(skill).then(amazonResult=>{
|
||||
console.log('Amazon : ' + amazonResult);
|
||||
if (amazonResult === 200 || amazonResult === 202) {
|
||||
//Skill uploaded, it's ok to update databaseI
|
||||
databaseHelper
|
||||
@@ -208,7 +219,9 @@ router.post ('/updateSkill/:id', async (req, res, next) => {
|
||||
.catch (e => {
|
||||
res.json ({result: -1, message: 'error'});
|
||||
});
|
||||
}
|
||||
}else{
|
||||
res.json({result: -1, message: 'amazon error : ' + amazonResult});
|
||||
}
|
||||
}).catch(e=>{
|
||||
res.json ({result: -1, message: e});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user