0
votes

In one intent of my skill have lot of records to display or read for user; i want to paginate response of that intent

Example:

User: how many announcements are in the system

Alexa: there are 6. first 4 are (announcement 1, announcement 2, announcement 3, announcement 4)

Do you want to hear more?

User: Yes

Alexa: Next 2 announcements are (announcement 5, announcement 6)

1

1 Answers

0
votes

Use AMAZON.YesIntent intent to capture "Yes" inputs from the user.

When the user asks for announcements use sessionAttributes along with your response to keep track of the read announcement indexes. So that when the user says "Yes", you can use this session attribute to read the next set of announcements. You can also set a STATE attribute too, so that you can validate the state in AMAZON.YesIntent handler before you give the next set of announcements.

Ex:

...
"sessionAttributes": {
    "announcements_index": [0,1,2,3],
    "STATE": "READ_ANNOUNCEMENTS"
  }
...

When the user say "Yes", in your AMAZON.YesIntent handler check whether the state is READ_ANNOUNCEMENTS and based on the announcements_index give the next set of announcements from your announcements list. And in sessionAttributes update the announcements_index.

There is chance that user might say "No", for "Do you want to hear more?". So add a AMAZON.NoIntent too and handle it accordingly.

Do not forget to clear announcements_index and STATE when use case is done.

More on sessionAttributes and Response Parameters here