-1

I have one Alexa skill which calls the external web service. My web service returns me variable array or string(Sentences) currently I am concatenating the whole array in the string and prompt it as a response.

Now, I want to add functionality like next, skip previous, last, first.

e.g. if I have an array of 5 in response. Now on a response from web service speak normally as I have concatenated all strings but if Alexa speaking 1 line and user say skip than Alexa skip the first line and start with 2nd. if the user says last than Alexa speak directly the last line.

Is it possible to achieve this functionality?

I am using node.js and dialogue for user input to call web service.

Vikrant
  • 4,920
  • 17
  • 48
  • 72
user3256309
  • 29
  • 10

1 Answers1

0

Yes, this is possible with AMAZON.NextIntent and AMAZON.PreviousIntent.

For Next use AMAZON.NextIntent

When your backend receives the initial request, query the external service and keep the array of sentences in in response sessionAttributes. You can also set a STATE attribute too, so that you can check this state in AMAZON.NextIntent or other pagination handlers before you give the sentence.

"sessionAttributes": {
    "sentences": ["This is the first sentence","This is the second sentence", ..  ],
    "index": 1,
    "STATE": "READING_SENTENCES"
  }

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

Similarly, for AMAZON.PreviousIntent decrement the index accordingly.

You can create two custom intents for Last and Skip (skip has same functionality as AMAZON.NextIntent, so you can add the utterance "Skip" in AMAZON.NextIntent)

When the user says "Last", say last sentence.

More on sessionAttributes and Response Parameters here

johndoe
  • 4,387
  • 2
  • 25
  • 40
  • but if user not give any input alexa need to speak all in sequnce Or suppose if user say skip while running 2nd sentence it start from 3rd sentence till end or user input – user3256309 Jul 26 '18 at 11:47
  • If the user didn't respond then you can make use of reprompt to say the rest of the sentences. – johndoe Jul 26 '18 at 12:00
  • I like to explain you actual scenario: 1) When user launch skill for example : Open e. b. s. 2) User Provide Input using 1st Prompt: Itemname 3) User provide input using 2nd Prompt: cust no 4) Web service call-> return N no of rows 5) Here it may be user skip any no or stop or listen ALL 6) after that user Input for continue or not : YES/NO 7) If yes than repeat from 1st else exit – user3256309 Jul 26 '18 at 12:19
  • If the user didn't respond, session will time out in 8 seconds and you can't change the time out length. In your case, when the user says "yes" to continue in step 6, respond with 1st question and take it from there accordingly. – johndoe Jul 26 '18 at 12:47