Search code examples
node.jsamazon-web-servicesalexa-skills-kit

Alexa Skill Kit - To save user input


Is there a way to save the user input to a variable in ALexa Skill kit.


Solution

  • When you are creating an intent using Skill Builder, you can specify the Slot using curly brackets.

    enter image description here

    You can also define a Slot Type. You can define your own types or choose from built-in types.

    enter image description here

    Check the complete list here: https://developer.amazon.com/docs/custom-skills/slot-type-reference.html

    From your Alexa skill (lambda function) you capture that a user is saying. You can get it from:

    this.event.request.intent.slots.<SlotName>.value
    

    Then you do with the value what do you want.

    Update:

    Interaction schema would be:

      {
        "name": "MyColorIsIntent",
        "samples": [
          "my favorite color is {Color}"
        ],
        "slots": [
          {
            "name": "Color",
            "type": "LIST_OF_COLORS"
          }
        ]
      },