npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

aws-lex-helpers

v0.9.6

Published

AWS Lex helper classes and functions to build responses

Readme

AWS Lex Helpers

npm version Build Status

AWS Lex helper classes and functions to build responses

Response Types

  • ElicitSlot - Informs Amazon Lex that the user is expected to provide a slot value in the response
  • ElicitIntent - Informs Amazon Lex that the user is expected to respond with an utterance that includes an intent
  • ConfirmIntent - Informs Amazon Lex that the user is expected to give a yes or no answer to confirm or deny the current intent
  • Close - Informs Amazon Lex not to expect a response from the user
  • Delegate - Directs Amazon Lex to choose the next course of action based on the bot configuration

View more details on Lex Documentation

Response Message Components

  • PlainTextMessage
  • ResponseCard
    • ResponseCardAttachment
      • AttachmentButton

Lambda Function Response Structure

Your lambda functions need to response in the following format

{
    "sessionAttributes": {
    "key1": "value1",
    "key2": "value2"
    ...
  },
  "dialogAction": {
    "type": "ElicitIntent, ElicitSlot, ConfirmIntent, Delegate, or Close",
    Full structure based on the type field. See below for details.
  }
}

Using this module, you can easily generate the above response like below.

  1. Generate the dialog action content using message components (ResponseCard,ResponseCardAttachment,AttachmentButton,PlainTextMessage)
  2. Generate the lambda response using the message component generated in step 1

Usage

Installation

npm install aws-lex-helpers --save

Initialization

const AWSLexHelpers = require('aws-lex-helpers');

// Response generator
const Responses = AWSLexHelpers.Responses;


// Message components
const {ResponseCard,ResponseCardAttachment,AttachmentButton,PlainTextMessage,Constants} = AWSLexHelpers;

Plain Text Message

let plainTextMessage = new PlainTextMessage()
                .setMessage('hey there this is a plain text message')
                .build();

Response Card

let firstAttachmentButton = new AttachmentButton()
        .setText('First Button')
        .setValue('first button')
        .build();

let secondAttachmentButton = new AttachmentButton()
        .setText('Second Button')
        .setValue('second button')
        .build();

let responseCardAttachment = new ResponseCardAttachment()
        .setTitle('Attachment Title')
        .setSubTitle('Attachment subtitle')
        .setImageUrl('<IMAGE_URL>') // Hosted url of the image
        .setAttachmentLinkUrl('<LINK_URL>') // URL to be opened once click on the image
        .setButtons([firstAttachmentButton, secondAttachmentButton])
        .build();
        
let responseCard = new ResponseCard()
        .setGenericAttachments([responseCardAttachment]) // Response card attachments can be provided as an array
        .build();

Generating lambda response

let sessionAttributes = {YOUR_SESSION_ATTRIBUTES};
let intentName = 'YOUR_INTENT_NAME';
let slots = {YOUR_SLOTS};

Elicit Slot

let slotToElicit = {YOUR_SLOTS_TO_ELICIT};

let response = Responses.elicitSlot(sessionAttributes, intentName, slots, slotToElicit, plainTextMessage,responseCard);

Elicit Intent

let response = Responses.elicitIntent(sessionAttributes, plainTextMessage, responseCard);

Confirm Intent

let response = Responses.confirmIntent(sessionAttributes, intentName, slots, plainTextMessage,responseCard);

Close Intent

let fulfillmentState = Constants.FULFILMENT_STATES.FULFILLED; // or FAILED

let response = Responses.close(sessionAttributes, fulfillmentState, plainTextMessage, responseCard);

Delegate Intent

let response = Responses.delegate(sessionAttributes, slots);

Return the response above from your lambda function

Additional Resources

Constants

  • FULFILMENT_STATES

    • FULFILLED
    • FAILED
  • INVOCATION_SOURCE

    • DIALOG_CODE_HOOK
    • FULFILMENT_CODE_HOOK