2
votes

I'm using lambda to create the skill, the same logic in hello world example. Is possible to get what user said? In Text?

const HelloWorldIntentHandler =  {
    canHandle(handlerInput) {
        return handlerInput.requestEnvelope.request.type === 'IntentRequest'
            && handlerInput.requestEnvelope.request.intent.name === 'HelloWorldIntentHandler';
    },
    async handle(handlerInput) {
  const speechText = 'Hello World!';

return handlerInput.responseBuilder
        .speak(speechText)
        //.reprompt('add a reprompt if you want to keep the session open for the user to respond')
        .getResponse();  

    }
};
1

1 Answers

1
votes

Alexa does not provide the full user input in text. So the only way to get what the user says is to use slots. Read about how to use Intents with Slots here.

Here are the different types of slots (slotTypes) that you can use to help Alexa extract the values you want from the user input. List of Slot Types.

If you don't know the specific type of data you want to get from the user, then you could use the slot type AMAZON.SearchQuery to capture phrases and sentences.

Then it should deliver at least more of the user input (as Alexa understood it) into that slot as text.

AMAZON.SearchQuery

As you think about what users are likely to ask, consider using a built-in or custom slot type to capture user input that is more predictable, and the AMAZON.SearchQuery slot type to capture less-predictable input that makes up the search query.