alexa-skills-kitalexa-slot

How to create Alexa Catalog for URL Reference for slots


I've found this example that is using the Catalog URL Reference for populating custom slots in Alexa Skill.

The problem is that I don't know how to populate this catalog.

I was able to create the model catalog using ask cli like this:

ask api create-model-catalog -n catalog_name -d "description"

That produces me the catalogId in the form "catalogId" : "amzn1.ask.interactionModel.catalog.blabla" like the one in the GitHub example in the first link.

The problem is that I don't know how to put the values (for example the ingredients.json in the above example) inside that catalog.

I've tried using

ask api create-model-catalog-version -c catalogId -f ingredients.json

But what I obtain is

Call create-model-catalog-version error.
Error code: 400
{
  "message": "Request is not valid.",
  "violations": [
    {
      "message": "'source' field of the request is invalid."
    }
  ]
}

In the documentation, there isn't an example of how to deal with this so I'm stuck at this point.

Thanks for your help


Solution

  • In order to create and use a catalog in your alexa skill, you have to:

    1. Upload the catalog file into a bucket or another public storage endpoint.

    2. After that, you have to specify a JSON file with the following content (eg. catalog.json):

    {
      "type": "URL",
      "url": "[your catalog url]"
    }
    
    1. Use the ask api to create the catalog, as you mentioned, to get your catalog-id:
    ask api create-model-catalog --catalog-name "IngredientsCatalog"
    --catalog-description "Ingredients"
    
    1. Create a model catalog version by using the file that contains your catalog URL:
    ask api create-model-catalog-version --file .\catalog.json --catalog-id [your catalog-id]
    
    1. This call will provide a command to track the create version status. Something like:
    ask api get-model-catalog-update-status -c [your catalog-id] -u [request id]
    
    1. If the version has been created successfully, then you can set it on your skill interaction model:
                "types": [
                    {
                        "name": "Ingredient",
                        "valueSupplier": {
                            "type": "CatalogValueSupplier",
                            "valueCatalog": {
                                "catalogId": "[your catalog-id]",
                                "version": "[the desired version number]"
                            }
                        }
                    }
                ]