From 63bdce34d86d6a5bfb72ac93c45e33da2a834f35 Mon Sep 17 00:00:00 2001 From: Oliver Atoa Date: Tue, 29 Jun 2021 22:58:13 +0000 Subject: [PATCH 1/3] add support for FallbackIntent --- CHANGELOG.md | 9 ++++-- README.md | 17 +++++++---- examples/zip-code/template.yaml | 12 +++++++- samconfig.toml | 2 +- .../lex_v2_cfn_cr/lex_v2_cfn_cr/intent.py | 30 +++++++++++++++++++ template.yaml | 6 ++-- 6 files changed, 64 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bfa54d8..62fb4d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.3.0] - 2021-06-30 +### Added +- Support for FallbackIntent + ## [0.2.0] - 2021-06-29 ### Added - New example based on QnABot Reponse bots. This example shows how to deploy @@ -29,6 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Initial release -[Unreleased]: https://github.com/aws-samples/aws-lex-v2-cfn-cr/compare/v0.2.0...develop -[0.2.0]: https://github.com/aws-samples/aws-lex-v2-cfn-cr/releases/tag/v0.1.0...v0.2.0 +[Unreleased]: https://github.com/aws-samples/aws-lex-v2-cfn-cr/compare/v0.3.0...develop +[0.3.0]: https://github.com/aws-samples/aws-lex-v2-cfn-cr/compare/v0.3.0...v0.3.0 +[0.2.0]: https://github.com/aws-samples/aws-lex-v2-cfn-cr/compare/v0.1.0...v0.2.0 [0.1.0]: https://github.com/aws-samples/aws-lex-v2-cfn-cr/releases/tag/v0.1.0 \ No newline at end of file diff --git a/README.md b/README.md index 5c181f9..f57f05f 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ Deployment options: Properties: Location: ApplicationId: arn:aws:serverlessrepo:us-east-1:777566285978:applications/lex-v2-cfn-cr - SemanticVersion: 0.2.0 + SemanticVersion: 0.3.0 Parameters: # Custom Resource Lambda log level LogLevel: 'INFO' @@ -172,6 +172,16 @@ Resources: value: What is your zipcode? maxRetries: 2 allowInterrupt: true + # The Fallback intent is automatically created by the Lex service + # This will update the default fallback intent + - intentName: FallbackIntent + description: Default fallback intent when no other intent matches + intentClosingSetting: + closingResponse: + messageGroups: + - message: + plainTextMessage: + value: Sorry I am having trouble understanding. # Creates an immutable Bot Version LexBotVersion: @@ -248,7 +258,7 @@ Lex APIS. ## Caveats -- CloudFormation Updates and creation events must complete within the Lambda +- CloudFormation update and creation events must complete within the Lambda limit of 15 minutes. This also includes building the Bot locales. This is enough time for the vast majority of bots. The poller functionality of the CrHelper library is not used to extend this time since larger bot definitions @@ -259,9 +269,6 @@ Lex APIS. CloudFormation again. You can also use the Lex export functionality to an get an existing working bot version and restore it into the current `DRAFT` using the Lex import functionality -- A default fallback intent will be automatically created per locale when you - initially deploy the bot. This default fallback intent cannot be modified - with this Custom Resource - Lex Bot Resource Policies are not implemented ## Development diff --git a/examples/zip-code/template.yaml b/examples/zip-code/template.yaml index 25fe8a2..3ce86ca 100644 --- a/examples/zip-code/template.yaml +++ b/examples/zip-code/template.yaml @@ -16,7 +16,7 @@ Parameters: Description: >- Semantic version of SAR Lex CloudFormation Custom Resource application Type: String - Default: 0.2.0 + Default: 0.3.0 Resources: # this deploys the Custom Resource as a nested CloudFormation stack @@ -55,6 +55,16 @@ Resources: regexFilter: pattern: '[0-9]{8}' CR.intents: + # The Fallback intent is automatically created by the Lex service + # This will update the default fallback intent + - intentName: FallbackIntent + description: Default fallback intent when no other intent matches + intentClosingSetting: + closingResponse: + messageGroups: + - message: + plainTextMessage: + value: Sorry I am having trouble understanding. - intentName: UpdateZipCode sampleUtterances: - utterance: i want to change my zip code diff --git a/samconfig.toml b/samconfig.toml index e65a1ff..9ee62fc 100644 --- a/samconfig.toml +++ b/samconfig.toml @@ -32,7 +32,7 @@ confirm_changeset = true capabilities = "CAPABILITY_IAM CAPABILITY_AUTO_EXPAND" tags = """ project="LexV2CfnCr" \ - version=0.2.0 \ + version=0.3.0 \ """ parameter_overrides = """ LogLevel=DEBUG \ diff --git a/src/lambda_functions/lex_v2_cfn_cr/lex_v2_cfn_cr/intent.py b/src/lambda_functions/lex_v2_cfn_cr/lex_v2_cfn_cr/intent.py index 2a4793c..249247c 100644 --- a/src/lambda_functions/lex_v2_cfn_cr/lex_v2_cfn_cr/intent.py +++ b/src/lambda_functions/lex_v2_cfn_cr/lex_v2_cfn_cr/intent.py @@ -347,6 +347,19 @@ def create_intent( self, input_parameters: Dict[str, Any] ) -> Union[CreateIntentResponseTypeDef, UpdateIntentResponseTypeDef]: """Create Intent""" + intent_name = input_parameters.get("intentName") + # fallback intent is automatically created with the locale and can only + # be updated. The intent has a fixed ID: "FALLBCKINT" + # It does not contain slots + if intent_name == "FallbackIntent": + return self._update_intent( + input_parameters={ + "intentId": "FALLBCKINT", + "parentIntentSignature": "AMAZON.FallbackIntent", + **input_parameters, + } + ) + response = self._create_intent(input_parameters=input_parameters) bot_id = response["botId"] bot_version = response["botVersion"] @@ -377,6 +390,14 @@ def create_intent( def delete_intent(self, input_parameters: Dict[str, Any]) -> None: """Delete Intent""" operation = "DeleteIntent" + intent_id = input_parameters.get("intentId") + # fallback intent is automatically created with the locale and can only + # be updated - not deleted. The intent has a fixed ID: "FALLBCKINT" + # ignoring deletes to avoid failures + if intent_id == "FALLBCKINT": + self._logger.warning("attempted to delete fallback intent - ignoring") + return + operation_parameters = get_api_parameters( operation=operation, input_parameters=input_parameters, @@ -403,6 +424,15 @@ def update_intent( "intentId": intent_id, **intent, } + intent_name = intent.get("intentName") + if intent_name == "FallbackIntent": + return self._update_intent( + input_parameters={ + "parentIntentSignature": "AMAZON.FallbackIntent", + **input_parameters, + } + ) + old_slots = ( old_intent[CUSTOM_ATTRIBUTES["slots"]] if CUSTOM_ATTRIBUTES["slots"] in old_intent diff --git a/template.yaml b/template.yaml index 1b77564..a5b64d7 100644 --- a/template.yaml +++ b/template.yaml @@ -3,7 +3,7 @@ AWSTemplateFormatVersion: 2010-09-09 Transform: AWS::Serverless-2016-10-31 # Keep version in sync with in Description, Mappings and Metadata Description: >- - Lex V2 CloudFormation Custom Resource (0.2.0) + Lex V2 CloudFormation Custom Resource (0.3.0) Parameters: LogLevel: @@ -34,7 +34,7 @@ Metadata: - Resource HomePageUrl: https://github.com/aws-samples/aws-lex-v2-cfn-cr # Keep version in sync with in Description, Mappings and Metadata - SemanticVersion: 0.2.0 + SemanticVersion: 0.3.0 SourceCodeUrl: https://github.com/aws-samples/aws-lex-v2-cfn-cr Mappings: @@ -42,7 +42,7 @@ Mappings: Application: Name: LexV2CfnCr # Keep version in sync with in Description, Mappings and Metadata - Version: 0.2.0 + Version: 0.3.0 ########################################################################## # SAM Globals From 8c7ced81d8acef2ac60f4be95092efefc614625a Mon Sep 17 00:00:00 2001 From: Oliver Atoa Date: Wed, 30 Jun 2021 17:42:02 +0000 Subject: [PATCH 2/3] add banker bot example and minor README changes --- CHANGELOG.md | 4 +- README.md | 5 + examples/banker-bot/README.md | 18 + examples/banker-bot/samconfig.toml | 15 + .../banker_bot/lambda_function.py | 118 ++++++ .../banker_bot/requirements.txt | 0 examples/banker-bot/template.yaml | 352 ++++++++++++++++++ 7 files changed, 511 insertions(+), 1 deletion(-) create mode 100644 examples/banker-bot/README.md create mode 100644 examples/banker-bot/samconfig.toml create mode 100644 examples/banker-bot/src/lambda_functions/banker_bot/lambda_function.py create mode 100644 examples/banker-bot/src/lambda_functions/banker_bot/requirements.txt create mode 100644 examples/banker-bot/template.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index 62fb4d8..d19d0ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [0.3.0] - 2021-06-30 ### Added -- Support for FallbackIntent +- Support to update the Fallback Intent +- Example bot based on the [AWS Workshop](https://amazonlex.workshop.aws/) to + illustrate how to configure Lambda CodeHooks and Conversation Logs ## [0.2.0] - 2021-06-29 ### Added diff --git a/README.md b/README.md index f57f05f..e0ea6f6 100644 --- a/README.md +++ b/README.md @@ -270,6 +270,11 @@ Lex APIS. an existing working bot version and restore it into the current `DRAFT` using the Lex import functionality - Lex Bot Resource Policies are not implemented +- The Custom Resource stack deploys a regular IAM Role instead of an IAM Service + Linked Role to be used with the Lex Bot. The SAR service does not currently + [support](https://docs.aws.amazon.com/serverlessrepo/latest/devguide/list-supported-resources.html) + Service Linked Roles. We may change this if support is added. You can create + your own Service Linked Role separately and use it in your template ## Development diff --git a/examples/banker-bot/README.md b/examples/banker-bot/README.md new file mode 100644 index 0000000..b0a3475 --- /dev/null +++ b/examples/banker-bot/README.md @@ -0,0 +1,18 @@ +This example deploys a Banker Bot based on the [Lex V2 Workshop](https://amazonlex.workshop.aws/) +which showcases various Lex V2 capabilities. + +The template shows how to attach a [Lambda Fulfillment Code Hook](https://docs.aws.amazon.com/lexv2/latest/dg/lambda.html) +and how to configure [Text Conversation Logs](https://docs.aws.amazon.com/lexv2/latest/dg/conversation-logs-configure.html) + +Before you use this example, you should deploy the Custom Resource stack +in your AWS account. The Custom Resource stack name is passed as a parameter +when deploying this example. This stack name parameter is used to import the +values of the Lambda function and the IAM role created by the Custom Resource. + +The bot in this example can be deployed using the +[AWS Serverless Application Model Command Line Interface (SAM CLI)](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html): + +```bash +sam build --use-container +sam deploy --guided +``` diff --git a/examples/banker-bot/samconfig.toml b/examples/banker-bot/samconfig.toml new file mode 100644 index 0000000..09d4631 --- /dev/null +++ b/examples/banker-bot/samconfig.toml @@ -0,0 +1,15 @@ +# https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-config.html +# https://aws.amazon.com/blogs/compute/optimizing-serverless-development-with-samconfig/ + +version=0.1 +[default.deploy.parameters] +stack_name = "lex-v2-cfn-cr-banker-bot" +s3_bucket = "lex-v2-cfn-cr-artifacts-506886316466-us-east-1" +s3_prefix = "sam-artifacts/lex-v2-cfn-banker-bot" +region = "us-east-1" +fail_on_empty_changeset = false +confirm_changeset = true +capabilities = "CAPABILITY_IAM CAPABILITY_AUTO_EXPAND" +parameter_overrides = """ + LexV2CfnCrStackName=lex-v2-cfn-cr \ +""" \ No newline at end of file diff --git a/examples/banker-bot/src/lambda_functions/banker_bot/lambda_function.py b/examples/banker-bot/src/lambda_functions/banker_bot/lambda_function.py new file mode 100644 index 0000000..7d7db66 --- /dev/null +++ b/examples/banker-bot/src/lambda_functions/banker_bot/lambda_function.py @@ -0,0 +1,118 @@ +""" +MIT No Attribution + +Copyright 2021 Amazon Web Services + +Permission is hereby granted, free of charge, to any person obtaining a copy of this +software and associated documentation files (the "Software"), to deal in the Software +without restriction, including without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +""" + +# https://amazonlex.workshop.aws/banker-bot/create-first-lambda.en.files/BankingBotEnglish.py + +import json +import random +import decimal + +def random_num(): + return(decimal.Decimal(random.randrange(1000, 50000))/100) + +def get_slots(intent_request): + return intent_request['sessionState']['intent']['slots'] + +def get_slot(intent_request, slotName): + slots = get_slots(intent_request) + if slots is not None and slotName in slots and slots[slotName] is not None: + return slots[slotName]['value']['interpretedValue'] + else: + return None + +def get_session_attributes(intent_request): + sessionState = intent_request['sessionState'] + if 'sessionAttributes' in sessionState: + return sessionState['sessionAttributes'] + + return {} + +def elicit_intent(intent_request, session_attributes, message): + return { + 'sessionState': { + 'dialogAction': { + 'type': 'ElicitIntent' + }, + 'sessionAttributes': session_attributes + }, + 'messages': [ message ] if message != None else None, + 'requestAttributes': intent_request['requestAttributes'] if 'requestAttributes' in intent_request else None + } + + +def close(intent_request, session_attributes, fulfillment_state, message): + intent_request['sessionState']['intent']['state'] = fulfillment_state + return { + 'sessionState': { + 'sessionAttributes': session_attributes, + 'dialogAction': { + 'type': 'Close' + }, + 'intent': intent_request['sessionState']['intent'] + }, + 'messages': [message], + 'sessionId': intent_request['sessionId'], + 'requestAttributes': intent_request['requestAttributes'] if 'requestAttributes' in intent_request else None + } + +def CheckBalance(intent_request): + session_attributes = get_session_attributes(intent_request) + slots = get_slots(intent_request) + account = get_slot(intent_request, 'accountType') + #The account balance in this case is a random number + #Here is where you could query a system to get this information + balance = str(random_num()) + text = "Thank you. The balance on your "+account+" account is $"+balance+" dollars." + message = { + 'contentType': 'PlainText', + 'content': text + } + fulfillment_state = "Fulfilled" + return close(intent_request, session_attributes, fulfillment_state, message) + +def FollowupCheckBalance(intent_request): + session_attributes = get_session_attributes(intent_request) + slots = get_slots(intent_request) + account = get_slot(intent_request, 'accountType') + #The account balance in this case is a random number + #Here is where you could query a system to get this information + balance = str(random_num()) + text = "Thank you. The balance on your "+account+" account is $"+balance+" dollars." + message = { + 'contentType': 'PlainText', + 'content': text + } + fulfillment_state = "Fulfilled" + return close(intent_request, session_attributes, fulfillment_state, message) + + +def dispatch(intent_request): + intent_name = intent_request['sessionState']['intent']['name'] + response = None + # Dispatch to your bot's intent handlers + if intent_name == 'CheckBalance': + return CheckBalance(intent_request) + elif intent_name == 'FollowupCheckBalance': + return FollowupCheckBalance(intent_request) + + raise Exception('Intent with name ' + intent_name + ' not supported') + +def lambda_handler(event, context): + response = dispatch(event) + return response diff --git a/examples/banker-bot/src/lambda_functions/banker_bot/requirements.txt b/examples/banker-bot/src/lambda_functions/banker_bot/requirements.txt new file mode 100644 index 0000000..e69de29 diff --git a/examples/banker-bot/template.yaml b/examples/banker-bot/template.yaml new file mode 100644 index 0000000..6b0a525 --- /dev/null +++ b/examples/banker-bot/template.yaml @@ -0,0 +1,352 @@ +--- +AWSTemplateFormatVersion: 2010-09-09 +Transform: AWS::Serverless-2016-10-31 + +Description: |- + Sample Lex V2 Banker Bot using CloudFormation Custom Resource imported + from a deployed stack. + + Based on https://amazonlex.workshop.aws/ + +Parameters: + LexV2CfnCrStackName: + Description: >- + Lex V2 Custom Resource Stack Name + Type: String + Default: lex-v2-cfn-cr + +Globals: + Function: + Runtime: python3.8 + +Resources: + LexBotPolicy: + Type: AWS::IAM::Policy + Properties: + PolicyName: !Sub "${AWS::StackName}-CloudWatchLogs" + PolicyDocument: + Version: 2012-10-17 + Statement: + - Effect: Allow + Action: + - logs:CreateLogStream + - logs:PutLogEvents + Resource: !GetAtt LexBotConversationLogs.Arn + Roles: + # Parse role name from ARN + - Fn::Select: + - 2 + - Fn::Split: + - "/" + - Fn::Select: + - 5 + - Fn::Split: + - ":" + - Fn::ImportValue: + Fn::Sub: + "${LexV2CfnCrStackName}-LexServiceLinkedRole" + + LexBotConversationLogs: + Type: AWS::Logs::LogGroup + Properties: + LogGroupName: !Sub "${AWS::StackName}-conversation-logs" + RetentionInDays: 90 + + LexBotFunction: + Type: AWS::Serverless::Function + Properties: + CodeUri: ./src/lambda_functions/banker_bot + Description: >- + Lex Banker Bot Fulfillment Function + Handler: lambda_function.lambda_handler + MemorySize: 128 + Timeout: 3 + + # Add resource policy to allow the Lex Bot Alias to invoke it + LexBotFunctionPermission: + Type: AWS::Lambda::Permission + Properties: + Action: lambda:InvokeFunction + FunctionName: !GetAtt LexBotFunction.Arn + Principal: lexv2.amazonaws.com + SourceArn: + !Sub "arn:${AWS::Partition}:lex:${AWS::Region}:${AWS::AccountId}:\ + bot-alias/${LexBot}/${LexBotAlias}" + + LexBot: + Type: Custom::LexBot + Properties: + ServiceToken: + !ImportValue + Fn::Sub: "${LexV2CfnCrStackName}-LexV2CfnCrFunctionArn" + botName: !Sub "${AWS::StackName}-BankerBot" + dataPrivacy: + childDirected: False + description: Example Banker bot to demonstrate Lex V2 capabilities + idleSessionTTLInSeconds: 300 + roleArn: + !ImportValue + Fn::Sub: "${LexV2CfnCrStackName}-LexServiceLinkedRole" + CR.botLocales: + - localeId: en_US + nluIntentConfidenceThreshold: 0.40 + voiceSettings: + voiceId: Ivy + CR.slotTypes: + - slotTypeName: accountType + valueSelectionSetting: + resolutionStrategy: TopResolution + slotTypeValues: + - sampleValue: + value: Checking + - sampleValue: + value: Savings + - sampleValue: + value: Credit + synonyms: + - value: credit card + - value: visa + - value: mastercard + - value: amex + - value: american express + CR.intents: + - intentName: FallbackIntent + description: Default fallback intent when no other intent matches + intentClosingSetting: + closingResponse: + messageGroups: + - message: + plainTextMessage: + value: >- + Sorry I am having trouble understanding. + Can you describe what you'd like to do in a few + words? I can help you find your account balance, + transfer funds and make a payment. + - intentName: Welcome + description: Welcome intent + sampleUtterances: + - utterance: Hi + - utterance: Hello + - utterance: I need help + - utterance: Can you help me? + intentClosingSetting: + closingResponse: + messageGroups: + - message: + plainTextMessage: + value: >- + Hi! I'm BB, the Banking Bot. How can I help you + today? + - intentName: CheckBalance + description: + Intent to check the balance in the specified account type + sampleUtterances: + - utterance: What’s the balance in my account ? + - utterance: Check my account balance + - utterance: What’s the balance in my {accountType} account ? + - utterance: How much do I have in {accountType} ? + - utterance: I want to check the balance + - utterance: Can you help me with account balance ? + - utterance: Balance in {accountType} + fulfillmentCodeHook: + enabled: True + outputContexts: + - name: contextCheckBalance + timeToLiveInSeconds: 90 + turnsToLive: 5 + CR.slots: + - slotName: accountType + CR.slotTypeName: accountType + valueElicitationSetting: + slotConstraint: Required + promptSpecification: + messageGroups: + - message: + plainTextMessage: + value: + For which account would you like your balance? + maxRetries: 2 + - slotName: dateOfBirth + CR.slotTypeName: AMAZON.Date + valueElicitationSetting: + slotConstraint: Required + promptSpecification: + messageGroups: + - message: + plainTextMessage: + value: >- + For verification purposes, what is your date of + birth? + maxRetries: 2 + - intentName: FollowupCheckBalance + description: >- + Intent to allow a follow-up balance check request without + authentication + sampleUtterances: + - utterance: How about my {accountType} account + - utterance: What about {accountType} + - utterance: And in {accountType} ? + fulfillmentCodeHook: + enabled: True + inputContexts: + - name: contextCheckBalance + CR.slots: + - slotName: accountType + CR.slotTypeName: accountType + valueElicitationSetting: + slotConstraint: Required + promptSpecification: + messageGroups: + - message: + plainTextMessage: + value: + For which account would you like your balance? + maxRetries: 2 + - slotName: dateOfBirth + CR.slotTypeName: AMAZON.Date + valueElicitationSetting: + slotConstraint: Required + promptSpecification: + messageGroups: + - message: + plainTextMessage: + value: >- + For verification purposes, what is your date of + birth? + maxRetries: 2 + defaultValueSpecification: + defaultValueList: + - defaultValue: '#contextCheckBalance.dateOfBirth' + - intentName: TransferFunds + description: Help user transfer funds between bank accounts + sampleUtterances: + - utterance: I want to transfer funds + - utterance: Can I make a transfer? + - utterance: I want to make a transfer + - utterance: >- + I'd like to transfer {transferAmount} from + {sourceAccountType} to {targetAccountType} + - utterance: >- + Can I transfer {transferAmount} to my {targetAccountType} + - utterance: Would you be able to help me with a transfer? + - utterance: Need to make a transfer + fulfillmentCodeHook: + enabled: False + intentConfirmationSetting: + declinationResponse: + messageGroups: + - message: + plainTextMessage: + value: The transfer has been cancelled + promptSpecification: + messageGroups: + - message: + plainTextMessage: + value: >- + Got it. So we are transferring {transferAmount} from + {sourceAccountType} to {targetAccountType}. + Can I go ahead with the transfer? + maxRetries: 2 + intentClosingSetting: + closingResponse: + messageGroups: + - message: + plainTextMessage: + value: >- + The transfer is complete. {transferAmount} should + now be available in your {targetAccountType} + account. + CR.slots: + - slotName: sourceAccountType + CR.slotTypeName: accountType + valueElicitationSetting: + slotConstraint: Required + promptSpecification: + messageGroups: + - message: + plainTextMessage: + value: + Which account would you like to transfer from? + maxRetries: 2 + - slotName: targetAccountType + CR.slotTypeName: accountType + valueElicitationSetting: + slotConstraint: Required + promptSpecification: + messageGroups: + - message: + plainTextMessage: + value: Which account are you transferring to? + maxRetries: 2 + - slotName: transferAmount + CR.slotTypeName: AMAZON.Number + valueElicitationSetting: + slotConstraint: Required + promptSpecification: + messageGroups: + - message: + plainTextMessage: + value: How much money would you like to transfer? + maxRetries: 2 + + LexBotVersion: + # Bot versions are deleted by the Bot on Stack Deletions + DeletionPolicy: Retain + # Version number changes between updates which cause a CloudFormation + # delete event since the version number is the physical resource ID. + # The following policies prevents deletion events + UpdateReplacePolicy: Retain + Type: Custom::LexBotVersion + Properties: + ServiceToken: + !ImportValue + Fn::Sub: "${LexV2CfnCrStackName}-LexV2CfnCrFunctionArn" + botId: !Ref LexBot + # botVersionLocaleSpecification is derived from the bot locales + CR.botLocaleIds: !GetAtt LexBot.botLocaleIds + CR.lastUpdatedDateTime: !GetAtt LexBot.lastUpdatedDateTime + + LexBotAlias: + # Alias is deleted by the Bot on Stack Deletions + DeletionPolicy: Retain + Type: Custom::LexBotAlias + Properties: + ServiceToken: + !ImportValue + Fn::Sub: "${LexV2CfnCrStackName}-LexV2CfnCrFunctionArn" + botId: !Ref LexBot + botAliasName: live + botVersion: !Ref LexBotVersion + botAliasLocaleSettings: + en_US: + enabled: True + # Lambda Code Hook + codeHookSpecification: + lambdaCodeHook: + lambdaARN: !GetAtt LexBotFunction.Arn + codeHookInterfaceVersion: "1.0" + conversationLogSettings: + # Text Conversation Logs to CloudWatch + textLogSettings: + - enabled: True + destination: + cloudWatch: + cloudWatchLogGroupArn: !GetAtt LexBotConversationLogs.Arn + logPrefix: !Sub "aws/lex/${LexBot}/${LexBotVersion}/" + +Outputs: + LexBotId: + Description: Lex Bot ID + Value: !Ref LexBot + + LexBotLocaleIds: + Description: Lex Bot Locale IDs + Value: !Join [",", !GetAtt LexBot.botLocaleIds] + + LexBotLatestVersion: + Description: Latest Lex Bot Version ID + Value: !Ref LexBotVersion + + LexBotAliasId: + Description: Lex Bot Alias ID + Value: !Ref LexBotAlias From 15017c7e5f199ecfcdd325e5705b1045a99551ce Mon Sep 17 00:00:00 2001 From: Oliver Atoa Date: Wed, 30 Jun 2021 17:58:49 +0000 Subject: [PATCH 3/3] update changelog link --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d19d0ba..e39dc16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Initial release [Unreleased]: https://github.com/aws-samples/aws-lex-v2-cfn-cr/compare/v0.3.0...develop -[0.3.0]: https://github.com/aws-samples/aws-lex-v2-cfn-cr/compare/v0.3.0...v0.3.0 +[0.3.0]: https://github.com/aws-samples/aws-lex-v2-cfn-cr/compare/v0.2.0...v0.3.0 [0.2.0]: https://github.com/aws-samples/aws-lex-v2-cfn-cr/compare/v0.1.0...v0.2.0 [0.1.0]: https://github.com/aws-samples/aws-lex-v2-cfn-cr/releases/tag/v0.1.0 \ No newline at end of file