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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@amaabca/aws-lex-custom-resources

v4.1.0

Published

AWS Lex infrastructure as code via the CDK

Downloads

123

Readme

AWS CDK - Lex V2

This package contains an AWS CDK wrapper to create, update and provision Lex V2 bots.

Features

  • Deploy Lex V2 bots easily and reliably between environments!
  • Define your Lex bots using best practices and Infrastructure as Code!
  • Automatically build/release Lex bot versions and aliases!

Installation

Using yarn:

$ yarn add @amaabca/aws-lex-custom-resources

Using npm:

$ npm install @amaabca/aws-lex-custom-resources

Usage

This example is extracted from the AWS OrderFlowersBot sample.

import { Construct } from 'constructs';
import { Stack } from 'aws-cdk-lib';
import {
  LexCustomResource,
  LexBotDefinition,
} from '@amaabca/aws-lex-custom-resources';

export default class MyCdkStack extends Stack {
  constructor(scope: Construct, id: string) {
    super(scope, id);

    // Setup our custom resource from the AWS Serverless Application Repo.
    // Application link: https://serverlessrepo.aws.amazon.com/applications/us-east-1/777566285978/lex-v2-cfn-cr
    const provider = new LexCustomResource(
      this,
      'LexV2CfnCustomResource',
      {
        semanticVersion: '0.3.0',
        logLevel: 'INFO',
      }
    );

    // The LexBotDefinition class is our main entry point to Lex bot creation.
    // Once we're happy with our bot definition, call `botDefinition.build()` to
    // generate the resource.
    const botDefinition = new LexBotDefinition(
      this,
      'OrderFlowersBot',
      provider.serviceToken(),
      {
        botName: 'OrderFlowersBot',
        dataPrivacy: {
          childDirected: false,
        },
        description: 'Bot to order flowers on the behalf of a user',
        idleSessionTTLInSeconds: 300,
        roleArn: provider.serviceLinkedRoleArn(),
      }
    );

    // Add a language for our bot to which we can add intents/slots and slot types.
    const locale = botDefinition.addLocale({
      localeId: 'en_US',
      nluIntentConfidenceThreshold: 0.40,
      voiceSettings: {
        voiceId: 'Ivy',
      },
    });

    locale.addSlotType({
      slotTypeName: 'FlowerTypes',
      description: 'Types of flowers to pick up',
      valueSelectionSetting: {
        resolutionStrategy: 'OriginalValue'
      },
      slotTypeValues: [
        { sampleValue: { value: 'lillies' } },
        { sampleValue: { value: 'roses' } },
        { sampleValue: { value: 'tulips' } },
      ],
    });

    const orderFlowers = locale.addIntent({
      intentName: 'OrderFlowers',
      description: 'Intent to order a bouquet of flowers for pick up',
      sampleUtterances: [
        { utterance: 'I would like to pick up flowers' },
        { utterance: 'I would like to order some flower' },
      ],
      intentConfirmationSetting: {
        promptSpecification: {
          messageGroups: [
            {
              message: {
                plainTextMessage: {
                  value: 'Okay, your {FlowerType} will be ready for pickup by {PickupTime} on {PickupDate}. Does this sound okay?',
                },
              },
            },
          ],
          maxRetries: 2,
        },
        declinationResponse: {
          messageGroups: [
            {
              message: {
                plainTextMessage: {
                  value: 'Okay, I will not place your order.'
                },
              },
            },
          ],
        },
      },
    });

    orderFlowers.addSlot({
      slotName: 'FlowerType',
      slotTypeName: 'FlowerTypes',
      description: 'The type of flowers to pick up',
      valueElicitationSetting: {
        slotConstraint: 'Required',
        promptSpecification: {
          messageGroups: [
            {
              message: {
                plainTextMessage: {
                  value: 'What type of flowers would you like to order?',
                },
              },
            },
          ],
          maxRetries: 2,
        },
      },
    });

    orderFlowers.addSlot({
      slotName: 'PickupDate',
      slotTypeName: 'AMAZON.Date',
      description: 'The date to pick up the flowers',
      valueElicitationSetting: {
        slotConstraint: 'Required',
        promptSpecification: {
          messageGroups: [
            {
              message: {
                plainTextMessage: {
                  value: 'What day do you want the {FlowerType} to be picked up?',
                },
              },
            },
          ],
          maxRetries: 2,
        },
      },
    });

    orderFlowers.addSlot({
      slotName: 'PickupTime',
      slotTypeName: 'AMAZON.Time',
      description: 'The time to pick up the flowers',
      valueElicitationSetting: {
        slotConstraint: 'Required',
        promptSpecification: {
          messageGroups: [
            {
              message: {
                plainTextMessage: {
                  value: 'At what time do you want the {FlowerType} to be picked up?',
                },
              },
            },
          ],
          maxRetries: 2,
        },
      },
    });

    // create/update the bot resource
    const bot = botDefinition.build();

    // create a version that automatically is built when the bot changes
    const version = bot.automaticVersion();

    // create an alias and assign it to the latest bot version
    bot.addAlias({
      botAliasName: 'live',
      botVersion: version.botVersion(),
      botAliasLocaleSettings: {
        en_US: {
          enabled: true
        },
      },
    });
  }
}

License

MIT