3

I'm using the AMAZON.DURATION built-int slot type to get data from my custom Alexa skill. This works perfectly and converts the given duration to an ISO-8601 duration format.

For example, the slot type successfully converts "ten minutes" to PT10M and I can get this data from the request object passed to my Lambda function.

However, I would also like to pass the unformatted "ten minutes" to my Lambda function, too.

Is this possible?

Daniel Widdis
  • 8,424
  • 13
  • 41
  • 63
syscll
  • 991
  • 1
  • 9
  • 25

2 Answers2

0

After much trial and error, I asked this same question in the Amazon Developer forums and the official response from Amazon is:

Hi, this isn't possible although it is an interesting request!

I ended up writing a manual conversion function in Python.

syscll
  • 991
  • 1
  • 9
  • 25
0

Should manually convert it. Below is the code snippet for nodejs to convert to minutes. Lets assume Alexa sends PT5M to Lambda

var time = "PT5M";
var res = time.substring(2, (time.length));
var mins;
var timelist = res.split("H");
if(timelist.length > 1){
    mins = +parseInt((timelist[0]*60),10)+parseInt((timelist[1].substring(0,(timelist[1].length-1))),10);
}else{
    mins = res.substring(0, (res.length-1));
}
console.log(mins);
Suneet Patil
  • 608
  • 9
  • 21