Use AWS Lex service with Botktit
Switch branches/tags
Nothing to show
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Update botkit-middleware-lex.js Jun 26, 2018
.gitignore initial commit May 4, 2017
README.md update readme example to use npm package name Jun 26, 2018
package-lock.json update package.json to publish to npm Jun 26, 2018
package.json update package.json to publish to npm Jun 26, 2018

README.md

Overview

This middleware allows you to send user input to AWS Lex. This gives you access to intent mapping, data slots, NLP, and other capabilites of the Lex service. You can use this middleware to extend your bots capabilites, add an interaction that lives in Lex to an existing bot, or to run a Lex bot with Botkit as the connector.

Setup

You will need an AWS Lex bot setup. Note the BotName, BotAlias, and AWS region when creating your Lex bot.

In order to use the aws-sdk LexRuntime, you will need to have your aws access keys configured properly for nodejs

Message Object

Adds data returned from the Lex api PostText method to incoming message object. Learn more about the PostText method here


        message.lex = {
            intent: 'STRING',
            slots: 'OBJECT',
            session: 'OBJECT' 
            message: 'STRING',
            dialogState: 'STRING',
            slotToElicit: 'STRING'
        }

Example Usage

var lex = require('botkit-middleware-lex')({
  botName: 'BotkitLex',
  botAlias: 'blex',
  region: 'us-east-1'
})

module.exports = function(controller) {
  
  controller.middleware.receive.use(lex.receive)

// Respond to all incoming text messages with the response from Lex
  controller.on('message_received', function(bot, message) {
    if (message.text) {
        
        bot.reply(message, message.lex.message)
        }   
  })

  
}