- Hands-On Chatbot Development with Alexa Skills and Amazon Lex
- Sam Williams
- 276字
- 2021-07-16 17:45:15
Creating a Lambda to handle the request
To handle the intents inside our new Alexa Skill, we need to create a Lambda function. This will contain all of the logic we need to understand the intent and send a reply to the user.
To create a Lambda, we can use any of the methods described in Chapter 2, Getting Started with AWS and Amazon CLI, but we're going to be using our local development setup. Navigate to your base Lambda folder and create a new folder called hello-alexa-skill. Inside that folder, we need to create a new index.js file and open it to create our function.
To start, we need to require in the alexa-sdk, which makes creating the logic for Alexa a lot easier:
const Alexa = require('alexa-sdk');
Because we are requiring it, we also need to make sure that we have it installed. In the command-line interface, navigate into your hello-alexa-skill folder and run the npm init command. This process creates a package information and allows you to install other packages in the folder. You can set the values as you go through the setup or use the defaults by hitting Enter. Once you've finished the setup, you'll have a file called package.json, which contains the configuration for this folder.
To install a new package and add it to our package.json file, we can run the npm install --save package-name command. We want to install ask-sdk, so we need to run npm install --save ask-sdk. When this command runs, you'll see a new folder is created, called node_modules, which contains all of the code in the installed npm packages.
- 智慧城市:大數(shù)據(jù)、互聯(lián)網(wǎng)時代的城市治理(第4版)
- 計算機網(wǎng)絡與數(shù)據(jù)通信
- 信息通信網(wǎng)絡建設安全管理概要2
- 計算機網(wǎng)絡原理與應用技術
- 物聯(lián)網(wǎng)長距離無線通信技術應用與開發(fā)
- WordPress Web Application Development
- 物聯(lián)網(wǎng)場景設計與開發(fā)(初級)
- 深入理解Nginx:模塊開發(fā)與架構(gòu)解析
- Web用戶查詢?nèi)罩就诰蚺c應用
- 計算機通信網(wǎng)絡安全
- 小型局域網(wǎng)組建
- Microservices Development Cookbook
- 新IP:面向泛在全場景的未來數(shù)據(jù)網(wǎng)絡
- Architecting Data:Intensive Applications
- 物聯(lián)網(wǎng)導論