res.say doesn't work for intentRequest
app.intent('tfc', {
'slots': {
'phonenumber': 'AMAZON.NUMBER'
},
'utterances': ['{|my} {|contact number} {|phone number} {|number} {|is} {-|phonenumber}']
}, (req, res)=>{
let number - req.slot('phonenumber');
let login = new TfcLogin();
login.sendOtp(number).then((data)=>{
res.say('Enter the otp received on your phone').shouldEndSession(false);
}).catch((error)=>{
res.say(`${error.message}`).prompt('What is your registered contact number').shouldEndSession(false);
})
})
This is a simple intent request, but it isn't working the way it should. TfcLogin is a class, and whole code is working fine, if there is an error it falls in the catch block, but res.say isn't working as expected. Here's the response that I received
{
"version": "1.0",
"response": {
"directives": [],
"shouldEndSession": true
},
"sessionAttributes": {},
"dummy": "text"
}
What could be the reason for this?
You need to return a promise from this function, doesn't look like you're?
Are you talking about the login.sendOtp(number) function call? If so, it is working fine, I am receiving response from the server.
No, you must return a Promise from the function. Try return login.sendOtp(number).... to begin with?
I have the same problem maybe:
https://github.com/artifactdev/alexa-fahrplan-dresden/blob/api-workaround/index.js#L92
if (resultObject !== undefined) { console.log(resultObject); response.say(resultObject[0]).send(); cardArray.push(JSON.stringify(resultObject[1])); return false; }
The resultObject[0] is a String and console.log() gives me the String but the response is always empty.
send in promise like this return(Promise.then((res)=> response.say(res.data.name).send())