Search code examples
alexa-skills-kitalexa-slot

How to Develop alexa to speak latest response again


In Details: Example: user:- asks About Cricket News. Alexa:- Reads about the new. If users says come again or replay user: Come again. Alexa: Must read it again what it spoke earlier.

How to handle this situation using webhooks.

Thanks in advance.


Solution

  • You can make use of sessionAttributes to keep track of the last response that Alexa spoke. Whenever you return a response just store the speech and re-prompt in sessionAttributes and whenever a ComeAgainIntent is triggered, take the value from the sessionAttributes and respond accordingly.

    Ex:

    ...
    "sessionAttributes": {
        "lastResponse": {
           "speech": "This was my last speech",
           "reprompt": "This was my lst reprompt"
        }
     }
    ...