Socket
Book a DemoInstallSign in
Socket

botkit-middleware-lex

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

botkit-middleware-lex

Middleware for using AWS Lex with Botkit

1.1.0
latest
Source
npmnpm
Version published
Weekly downloads
2
-71.43%
Maintainers
1
Weekly downloads
 
Created
Source

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 Recieve Middleware

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)
        }   
  })
}

Example Usage Hears Middleware

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

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

 // listen for a specific Lex Intent
  controller.hears(['default_intent'], 'message_received', function(bot, message) {
    if (message.text) {
            bot.reply(message, message.lex.message)
        }   
  })
}

Keywords

botkit

FAQs

Package last updated on 03 Aug 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.