Search code examples
aws-lambdaalexa-skills-kit

Amazon Skill Flow Builder timeout and fallback for reprompts and recaps


I can't find a solution in Skill Flow Builder for detecting how often a reprompt or recap is returned so that I can force a fallback route after 2-3 attempts at prompting the user.

Does anyone have a solution?

Here's a typical example:

@welcome
    *say 
        Hello. Where do you want to go?
    *reprompt
        Where to go?
    *recap
        Where to go?
    *then
        hear route A {
            -> route_a
        }
        hear route B {
            -> route_b
        }

The problem with this is unless you say "route A" or "route B" you will get the reprompts forever.

It needs a fallback that you can define to trigger after so many attempts to get a correct response.


Solution

  • If you define hear *, SFB driver will route the behavior to it instead of just repeating the *recap message.

    Example of # of time variation recap would look something like:

    @start
    *say
        hello.
        Do you go to left or right?
    *reprompt
        Do you want to go left, or right?
    *recap
        This is a recap message.
    *then
         hear left {
            set repromptCount as 0
            -> left room
         }
    
         hear right {
            set repromptCount as 0
            -> right room
         }
    
         hear * {
            increase repromptCount by 1
            set limit as 3
            if repromptCount < limit {
            -> start *recap
            }
    
            set repromptingDestination as 'reprompting destination'
            -> too many reprompts scene        
         }
    
    @left room
    *say
        left room
    
    @right room
    *say
        right room
    
    @too many reprompts scene
    *say
        You didn't know what to do too much.
    *then
        -> {repromptingDestination}
    
    @reprompting destination
    *say
        Reprompt destination