简体   繁体   中英

How to create shared slots for alexa skills

I need help with creating shared slots. I visited the official page: https://developer.amazon.com/en-US/docs/alexa/smapi/create-a-slot-type-to-use-in-multiple-skills.html#api-endpoint-and-header

however, I am unable to understand how to initiate the process of creating shared slots. Can someone guide me?

You need to use ask cli , I assume you've already installed and configured it on your machine in order to deploy skill. If so - skip the first section:

  1. Install ask cli tool according to ASK CLI Quick Start
  2. Once it's installed and configured you need to generate auth token using your client-id and secret from your Security Profile , configured to Use SMAPI :

ask util generate-lwa-tokens --client-id <your-client-id> --client-confirmation <your-client-secret>

  1. It should open the website, click Allow and go back to the console, there should be something like:
The LWA tokens result:
{
  "access_token": "Atza|IwEBIJDuJivzzkceXtesWGS5tYIKRZlK0NKp9OWP8TXh4HlFSQxTiMD4V-1QeoSHa8C6(...)",
  "refresh_token": "Atzr|IwEBIOyzzw_7(...)",
  "token_type": "bearer",
  "expires_in": 3600,
  "expires_at": "2020-06-03T13:21:04.922Z"
}
  1. Copy the access_token and use it in Authentication header: Authorization: Bearer access_token in requests from the doc site you've linked.

Hint: you can obtain your vendorId here:

curl --location --request GET 'https://api.amazonalexa.com/v1/vendors' \
--header 'Authorization: Bearer access_token'

Sample CURL request:

curl --location --request POST 'http://api.amazonalexa.com/v1/skills/api/custom/interactionModel/slotTypes/' \
--header 'Authorization: Bearer access_token' \
--header 'Content-Type: application/json' \
--data-raw '{
     "vendorId": "MBT******E",
     "slotType": {
         "name": "SharedSlot",
         "description": "Your shared slot'\''s description"
     }
  }'

and response:

{
    "slotType": {
        "id": "amzn1.ask.interactionModel.slotType.e4fc2751-e4be-48c5-9be0-cd193a2ffafb"
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM