0

I get a list of rows from an API call inside my lambda. I want my alexa skill intent to read a row at a time and read the next only after confirmation.

How can I achieve that?

Thanks! Anshuman

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
Anshuman
  • 577
  • 1
  • 8
  • 23
  • you could give a little more details on what you have achieved or tried, but in general session attributes for alexa could help, something similar to this https://developer.amazon.com/blogs/alexa/post/2279543b-ed7b-48b4-a3aa-d273f7aab609/alexa-skill-recipe-using-session-attributes-to-enable-repeat-responses – Edwin Oct 10 '18 at 22:04
  • Hello Anshuman. Please add more details to your question. I published a skill with this functionality, however, I do not know if it will be of use to you. Can you add details such as what language are you using, SDK version, the response you get when doing the get request, etc? – Cai Cruz Oct 11 '18 at 02:58

1 Answers1

2

You can make use of sessionAttributes to read row by row. When your backend receives the initial request, query the external service and respond back with the first row and keep the array of rows in sessionAttributes. You can also set a STATE attribute too, so that you can check this state in AMAZON.YesIntent or other confirmation handlers before you give the next row. This STATE attribute will help you to validate whether the confirmation is actually for reading next row.

Ex:

"sessionAttributes": {
    "row": ["This is the first row","This is the second row", ..  ],
    "index": 1,
    "STATE": "READING_ROWS"
  }

Since you want the users to confirm before reading the second row, you should append some confirmation message also with the response.

Ex: "This is the first row. Do you want to hear more?"

Use AMAZON.YesIntent and AMAZON.NoIntent

When the user say "next" check whether the state is READING_ROWS and based on the index give the next item from your list. And in sessionAttributes increment the index.

Similarly, for AMAZON.NoIntent provide a proper response when the users denies.

More on sessionAttributes and Response Parameters here

johndoe
  • 4,387
  • 2
  • 25
  • 40