LEX SDK
Overview
With LEX SDK for Node.js (TypeScript), you can create Amazon Lex code in the same way as Alexa SDK V2.
Version
0.1.2
Install
npm install --save lex-sdk
Importing Dependencies
JavaScript
const Lex = require('lex-sdk');
TypeScript
import * as Lex from 'lex-sdk';
Adding Request Handlers
The following code example shows how to configure a handler to be invoked when the skill receives the OrderFlowers(Intent).
JavaScript
const OrderIntentHandler = { return hintentName == 'OrderFlowers' } { if hsource === LexInvocationSourceDialogCodeHook return hresponseBuilder else // FulfillmentCodeHook const message = contentType: LexContentTypePlainText content: `Thank you for your order.` ; return hresponseBuilder }
TypeScript
Adding Error Handler
The error handler is suitable for injecting unprocessed requests, error handling logic. In the next sample, the bot will return an error message if all errors occur.
JavaScript
const ErrorHandler = { return true; } { const message = contentType: LexContentTypePlainText content: "ERROR " + errormessage ; return hresponseBuilder }
TypeScript
Creating the Lambda Handler
The entry point of the Lambda function.
The following code example is an example of processing requests to all Lambda with SDK.
JavaScript
let bot;exports { if !bot bot = Lex ; return bot;}
TypeScript
;exports.handler =