Module

Amazon.Alexa.LanguageModel

Package
purescript-alexa
Repository
twitchard/purescript-alexa

#LanguageModel Source

type LanguageModel = { intents :: Array { name :: String, samples :: Array String, slots :: Array { name :: String, type :: String } }, invocationName :: String, types :: Array { name :: String, values :: Array { name :: { synonyms :: Array String, value :: String } } } }

LanguageModel is the type of the object that you provide to Amazon in order to define the voice interface or 'interaction model' for your skill, and defines the 'intents' and 'slots' that Alexa should listen for and pass along to your skill.

Intents

The 'intents' array may include Amazon built-in intents -- for example:

   {
     "name": "AMAZON.HelpIntent",
     "samples": [],
     "slots": []
   },

For a built-in intent you should not provide any slots or samples.

The 'intents' array may also include custom intents, that you define yourself. For example:

"intents": [
   {
     "name": "FavoriteProgrammingLanguageIntent",
     "samples": [
       "My favorite programming language is {Lang}",
       "My favorite language is {Lang}",
       "I like {Lang} the most",
       "The programming language I most enjoy using is {Lang}"
     ],
     "slots": [
       {
         "name": "Lang",
         "type": "ProgrammingLanguage"
       }
     ]
   },
   ...

Provide as many samples as you can think of -- this is how Alexa learns what phrases to interpret as belonging to an intent.

Slots

A 'slot' is a placeholder for a user-specified value. Your slot must have a 'type', which helps Alexa listen for certain values that are likely to be said. For example, a "types of trees" slot type vs. a "vacation spots" slot type might help Alexa hear "beech" and not "beach".

Amazon provides built-in slot types, and you may also define your own slot types by defining them inside the 'types' array in your language model. For example

"types": [
  {
    "name": "ProgrammingLanguage",
    "values": [
      {
        "name": {
          "synonyms": [],
          "value": "purescript"
        }
      },
      {
        "name": {
          "synonyms": [],
          "value": "java"
        }
      },
      ...
    ]
  }
]

Alexa will use the values of your slot types as hints, but will not consider them to be exhaustive. Alexa might very well invoke your skill and specify a value for the slot that does not appear in the list.

Deployment

If you are using the ASK CLI tools, you should serialize an object of type

{ interactionModel :: { languageModel :: LanguageModel } }

to JSON and place it in (for example) /models/en-US.json.

Your language model can be deployed with the command

ask deploy --target model`