Search code examples
node.jsalexa-skills-kit

Alexa Responses and Response Builder


I have certain doubts related to Alexa responses.

1. this.emit(':ask', speechOutput, repromptSpeech)

I know that this.emit(':tell',speechOutput) will cause alexa to speak the speechOutput and then close the session, and this.emit(':ask', speechOutput, repromptSpeech) will not close the session, and Alexa will wait for user Input. But where will this new input (given by the user) be stored. For eg:

User: What is the day on 2nd of "blah blah blah" {This was supposed to be a slot input}

Alexa: Sorry I didn't get the date /*speechOutput*/ . Will you repeat it for me? /*repromptSpeech*/

User: It was 2nd of January, 2018.

Now where will this new information 2nd of January, 2018 will be stored. Is there any function where I can pass a parameter which will store the new response of the user?

2. `this.emit(':responseReady')`

If I use this.response.speak(speechOutput) multiple times in my skill without calling the function this.emit(':responseReady'), will it work as expected, or will Alexa just speak the speechOutput which is encountered first?

3. How to make the conversation interactive?

In my skill I'm providing a lot of data to the user which is not good. What I was doing till now is:

  • I. Get the result from web

  • II. Build a single response (speechOutput) of all the data (which contains more than 100 lines)

  • III. Speak the speechOutput using this.emit(':tell',speechOutput)

But I want to know is there a way so that I can give 2 or 3 lines of response to user and then ask 'Do you want to know more?'. And based on the answer of the user i.e. 'Yes' or 'No', I will tell more results or just exit from the skill.


Solution

  • Yes you can provided 2 or 3 line response using SSML and emit ask so that alexa mic are open to take input from the user depending upon what type of question you are putting up you have to handle the intent like "Do you Know more" the probable response from user would be Amazon.Yes/ Amazon.No. Use states to have better intent mapping.