开源项目 `skill-sample-nodejs-howto` 使用教程

开源项目 skill-sample-nodejs-howto 使用教程

skill-sample-nodejs-howtoThis tutorial will walk first-time Alexa skills developers through all the required steps involved in creating a parameter-based skill using a template called ‘Minecraft Helper’. Ask how to craft an item, and this skill will give you instructions.项目地址:https://gitcode.com/gh_mirrors/sk/skill-sample-nodejs-howto

1. 项目的目录结构及介绍

skill-sample-nodejs-howto/
├── lambda/
│   ├── custom/
│   │   ├── index.js
│   │   ├── package.json
│   │   ├── util.js
│   │   └── test/
│   └── event-samples/
├── models/
│   ├── en-US.json
│   └── es-ES.json
├── skill.json
└── README.md
  • lambda/: 包含项目的核心代码和测试文件。

    • custom/: 包含主要的业务逻辑代码。
      • index.js: 项目的入口文件,处理主要的业务逻辑。
      • package.json: 项目的依赖管理文件。
      • util.js: 包含一些通用的工具函数。
      • test/: 包含项目的测试文件。
    • event-samples/: 包含用于测试的事件样本。
  • models/: 包含不同语言的语音模型文件。

    • en-US.json: 英语(美国)的语音模型文件。
    • es-ES.json: 西班牙语(西班牙)的语音模型文件。
  • skill.json: 项目的配置文件,定义了技能的基本信息和配置。

  • README.md: 项目的说明文档。

2. 项目的启动文件介绍

项目的启动文件是 lambda/custom/index.js。该文件是整个项目的入口点,负责处理用户的请求并返回相应的响应。以下是 index.js 的主要内容:

const Alexa = require('ask-sdk-core');
const handlers = require('./handlers');

exports.handler = Alexa.SkillBuilders.custom()
    .addRequestHandlers(
        handlers.LaunchRequestHandler,
        handlers.HelloWorldIntentHandler,
        handlers.HelpIntentHandler,
        handlers.CancelAndStopIntentHandler,
        handlers.SessionEndedRequestHandler
    )
    .lambda();
  • Alexa: 引入了 ask-sdk-core 库,用于构建 Alexa 技能。
  • handlers: 引入了 handlers.js 文件,其中定义了各种请求处理程序。
  • exports.handler: 定义了 Lambda 函数的处理程序,将不同的请求处理程序注册到技能中。

3. 项目的配置文件介绍

项目的配置文件是 skill.json。该文件定义了技能的基本信息、意图、槽位等配置。以下是 skill.json 的部分内容:

{
  "manifest": {
    "publishingInformation": {
      "locales": {
        "en-US": {
          "summary": "Sample Short Description",
          "examplePhrases": [
            "Alexa open hello world",
            "Alexa tell hello world hello",
            "Alexa ask hello world say hello"
          ],
          "name": "helloWorld",
          "description": "Sample Full Description"
        }
      },
      "isAvailableWorldwide": true,
      "testingInstructions": "Sample Testing Instructions.",
      "category": "EDUCATION_AND_REFERENCE",
      "distributionCountries": []
    },
    "apis": {
      "custom": {}
    },
    "manifestVersion": "1.0"
  }
}
  • manifest: 包含技能的发布信息和 API 配置。
    • publishingInformation: 包含技能的发布信息,如名称、描述、示例短语等。
    • apis: 定义了技能的 API 配置。
    • manifestVersion: 指定技能的清单版本。

通过以上配置,开发者可以定义技能的行为和功能,使其能够响应用户的请求并提供相应的服务。

skill-sample-nodejs-howtoThis tutorial will walk first-time Alexa skills developers through all the required steps involved in creating a parameter-based skill using a template called ‘Minecraft Helper’. Ask how to craft an item, and this skill will give you instructions.项目地址:https://gitcode.com/gh_mirrors/sk/skill-sample-nodejs-howto

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

缪阔孝Ruler

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值