如何用JSON格式提交Alexa Skill的意图槽位及话语定义?
Answer
Absolutely! You don’t have to slog through the GUI builder when you’ve got tons of auto-generated intent utterances—using raw JSON to manage your Alexa Skill’s interaction model is not only allowed, it’s the go-to method for bulk updates and code-driven workflows. Here’s how to do it two practical ways:
Option 1: Use the ASK CLI (Recommended for Code-Driven Workflows)
The Alexa Skills Kit Command Line Interface is built exactly for scenarios like this. Once set up, you can edit your entire interaction model as a local JSON file and deploy changes in one command:
- First, install and configure the ASK CLI (follow official setup steps from Alexa’s documentation if you need guidance)
- Pull your existing skill’s code and model to your local machine with
ask clone - Navigate to the
skill-package/interactionModels/customfolder—you’ll find language-specific JSON files (likeen-US.json) that define all your intents, slots, and utterances - Replace or edit this JSON with your auto-generated content (just make sure it follows Alexa’s official interaction model schema)
- Deploy the updated model with
ask deploy
Example Snippet of a Valid Interaction Model JSON
{ "interactionModel": { "languageModel": { "invocationName": "my custom skill", "intents": [ { "name": "GetWeatherIntent", "slots": [ { "name": "City", "type": "AMAZON.City" } ], "samples": [ "what's the weather in {City}", "how's the weather looking in {City}", "tell me the forecast for {City}" ] } ], "types": [] } } }
Option 2: Import JSON Directly in the GUI
If you don’t want to mess with command lines, the GUI builder has a hidden (but super useful) import/export feature:
- Go to your skill’s Build tab
- Under Interaction Model, click Import/Export (usually in the top-right corner of the Intents page)
- Select Import Skill Model and upload your properly formatted JSON file
- After uploading, click Build Model to apply all your changes at once
Pro Tips to Avoid Headaches
- Always validate your JSON against Alexa’s schema before importing/deploying—invalid syntax will throw errors
- For auto-generated utterances, skip duplicate samples (Alexa ignores them anyway, so no need to waste space)
- If you’re using custom slots, make sure their types are defined in the JSON’s
typessection, or match Alexa’s built-in slot types (likeAMAZON.NUMBER)
内容的提问来源于stack exchange,提问作者Robert Oschler
相关产品推荐
相关产品推荐

