Skip to content

Resource: awsLexBot

Provides an Amazon Lex Bot resource. For more information see Amazon Lex: How It Works

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.lexBot.LexBot(this, "order_flowers_bot", {
  abortStatement: {
    message: [
      {
        content: "Sorry, I am not able to assist at this time",
        contentType: "PlainText",
      },
    ],
  },
  childDirected: false,
  clarificationPrompt: {
    maxAttempts: 2,
    message: [
      {
        content: "I didn't understand you, what would you like to do?",
        contentType: "PlainText",
      },
    ],
  },
  createVersion: false,
  description: "Bot to order flowers on the behalf of a user",
  idleSessionTtlInSeconds: 600,
  intent: [
    {
      intentName: "OrderFlowers",
      intentVersion: "1",
    },
  ],
  locale: "en-US",
  name: "OrderFlowers",
  processBehavior: "BUILD",
  voiceId: "Salli",
});

Argument Reference

The following arguments are supported:

  • abortStatement - (Required) The message that Amazon Lex uses to abort a conversation. Attributes are documented under statement.
  • childDirected - (Required) By specifying true, you confirm that your use of Amazon Lex is related to a website, program, or other application that is directed or targeted, in whole or in part, to children under age 13 and subject to COPPA. For more information see the Amazon Lex FAQ and the Amazon Lex PutBot API Docs.
  • clarificationPrompt - (Required) The message that Amazon Lex uses when it doesn't understand the user's request. Attributes are documented under prompt.
  • createVersion - (Optional) Determines if a new bot version is created when the initial resource is created and on each update. Defaults to false.
  • description - (Optional) A description of the bot. Must be less than or equal to 200 characters in length.
  • detectSentiment - (Optional) When set to true user utterances are sent to Amazon Comprehend for sentiment analysis. If you don't specify detectSentiment, the default is false.
  • enableModelImprovements - (Optional) Set to true to enable access to natural language understanding improvements. When you set the enableModelImprovements parameter to true you can use the nluIntentConfidenceThreshold parameter to configure confidence scores. For more information, see Confidence Scores. You can only set the enableModelImprovements parameter in certain Regions. If you set the parameter to true, your bot has access to accuracy improvements. For more information see the Amazon Lex Bot PutBot API Docs.
  • idleSessionTtlInSeconds - (Optional) The maximum time in seconds that Amazon Lex retains the data gathered in a conversation. Default is 300. Must be a number between 60 and 86400 (inclusive).
  • locale - (Optional) Specifies the target locale for the bot. Any intent used in the bot must be compatible with the locale of the bot. For available locales, see Amazon Lex Bot PutBot API Docs. Default is enUs.
  • intent - (Required) A set of Intent objects. Each intent represents a command that a user can express. Attributes are documented under intent. Can have up to 250 Intent objects.
  • name - (Required) The name of the bot that you want to create, case sensitive. Must be between 2 and 50 characters in length.
  • nluIntentConfidenceThreshold - (Optional) Determines the threshold where Amazon Lex will insert the AMAZON.FallbackIntent, AMAZON.KendraSearchIntent, or both when returning alternative intents in a PostContent or PostText response. AMAZON.FallbackIntent and AMAZON.KendraSearchIntent are only inserted if they are configured for the bot. For more information see Amazon Lex Bot PutBot API Docs This value requires enableModelImprovements to be set to true and the default is 0. Must be a float between 0 and 1.
  • processBehavior - (Optional) If you set the processBehavior element to build, Amazon Lex builds the bot so that it can be run. If you set the element to save Amazon Lex saves the bot, but doesn't build it. Default is save.
  • voiceId - (Optional) The Amazon Polly voice ID that you want Amazon Lex to use for voice interactions with the user. The locale configured for the voice must match the locale of the bot. For more information, see Available Voices in the Amazon Polly Developer Guide.

intent

Identifies the specific version of an intent.

  • intentName - (Required) The name of the intent. Must be less than or equal to 100 characters in length.
  • intentVersion - (Required) The version of the intent. Must be less than or equal to 64 characters in length.

message

The message object that provides the message text and its type.

  • content - (Required) The text of the message.
  • contentType - (Required) The content type of the message string.
  • groupNumber - (Optional) Identifies the message group that the message belongs to. When a group is assigned to a message, Amazon Lex returns one message from each group in the response.

prompt

Obtains information from the user. To define a prompt, provide one or more messages and specify the number of attempts to get information from the user. If you provide more than one message, Amazon Lex chooses one of the messages to use to prompt the user.

  • maxAttempts - (Required) The number of times to prompt the user for information.
  • message - (Required) A set of messages, each of which provides a message string and its type. You can specify the message string in plain text or in Speech Synthesis Markup Language (SSML). Attributes are documented under message.
  • responseCard - (Optional) The response card. Amazon Lex will substitute session attributes and slot values into the response card. For more information, see Example: Using a Response Card.

statement

A statement is a map with a set of message maps and an optional response card string. Messages convey information to the user. At runtime, Amazon Lex selects the message to convey.

  • message - (Required) A set of messages, each of which provides a message string and its type. You can specify the message string in plain text or in Speech Synthesis Markup Language (SSML). Attributes are documented under message.
  • responseCard - (Optional) The response card. Amazon Lex will substitute session attributes and slot values into the response card. For more information, see Example: Using a Response Card.

Timeouts

Configuration options:

  • create - (Default 5M)
  • update - (Default 5M)
  • delete - (Default 5M)

Attributes Reference

In addition to all arguments above, the following attributes are exported:

  • checksum - Checksum identifying the version of the bot that was created. The checksum is not included as an argument because the resource will add it automatically when updating the bot.
  • createdDate - The date when the bot version was created.
  • failureReason - If status is FAILED, Amazon Lex provides the reason that it failed to build the bot.
  • lastUpdatedDate - The date when the $LATEST version of this bot was updated.
  • status - When you send a request to create or update a bot, Amazon Lex sets the status response element to BUILDING. After Amazon Lex builds the bot, it sets status to READY. If Amazon Lex can't build the bot, it sets status to FAILED. Amazon Lex returns the reason for the failure in the failure_reason response element.
  • version - The version of the bot.

Import

Bots can be imported using their name.

$ terraform import aws_lex_bot.order_flowers_bot OrderFlowers