alexa-js / alexa-app

A framework for Alexa (Amazon Echo) apps using Node.js
https://www.youtube.com/watch?v=pzM4jv7k7Rg
MIT License
1.03k stars 212 forks source link

Support for including utterances/ samples in slots #358

Open abdulkaderjeelani opened 6 years ago

abdulkaderjeelani commented 6 years ago

Now the schema's slot is an object that takes a map. Doc says "The slots object is a simple name: type mapping. The type must be one of Amazon's built-in slot types, such as AMAZON.DATE or AMAZON.NUMBER." If we require to specify a list of samples, for a slot it is not possible. This is especially useful when modeling a dialog flow. see https://raw.githubusercontent.com/alexa/alexa-cookbook/master/feature-demos/skill-demo-plan-my-trip/models/en-IN.json

In code it is explicitly passed as empty array. Changing the value of the map from string to object should do.


if (intent.slots && Object.keys(intent.slots).length > 0) {
        intentSchema["slots"] = [];
        for (key in intent.slots) {
          //  It's unclear whether `samples` is actually used for slots,
          // but the interaction model will not build without an (empty) array
          intentSchema.slots.push({
            "name": key,
            "type": intent.slots[key],
            "samples": []
          });
        }
      }
      schema.intents.push(intentSchema);
    }
dblock commented 6 years ago

Care to pull request a fix for this?

matt-kruse commented 6 years ago

Comment added on the PR. Merge and release soon?