--- AWSTemplateFormatVersion: 2010-09-09 Transform: AWS::Serverless-2016-10-31 Description: Sample Lex V2 Zip Code Bot using the CloudFormation Custom Resource from an Serverless Application Repository (SAR) nested stack Parameters: SarAppArn: Description: >- ARN of SAR Lex CloudFormation Custom Resource application Type: String Default: arn:aws:serverlessrepo:us-east-1:777566285978:applications/lex-v2-cfn-cr SarAppVersion: Description: >- Semantic version of SAR Lex CloudFormation Custom Resource application Type: String Default: 0.3.0 Resources: # this deploys the Custom Resource as a nested CloudFormation stack LexV2CfnCr: Type: AWS::Serverless::Application Properties: Location: ApplicationId: !Ref SarAppArn SemanticVersion: !Ref SarAppVersion Parameters: # Custom Resource Lambda log level LogLevel: DEBUG LexBot: Type: Custom::LexBot Properties: # this references the Lambda function created by the Custom Resource stack ServiceToken: !GetAtt LexV2CfnCr.Outputs.LexV2CfnCrFunctionArn botName: !Sub "${AWS::StackName}-ZipCodeUpdate" dataPrivacy: childDirected: True description: Test bot deployed using CloudFormation Custom Resource idleSessionTTLInSeconds: 300 # this references the role created by the Custom Resource stack roleArn: !GetAtt LexV2CfnCr.Outputs.LexServiceLinkedRole CR.botLocales: - localeId: en_US nluIntentConfidenceThreshold: 0.40 voiceSettings: voiceId: Salli CR.slotTypes: - slotTypeName: ZipCodeType parentSlotTypeSignature: AMAZON.AlphaNumeric valueSelectionSetting: resolutionStrategy: OriginalValue 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 - utterance: i have a new zip code - utterance: my new zip code is {ZipCode} CR.slots: - slotName: ZipCode CR.slotTypeName: ZipCodeType valueElicitationSetting: slotConstraint: Required promptSpecification: messageGroups: - message: plainTextMessage: value: What is your zipcode? maxRetries: 2 allowInterrupt: true 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: !GetAtt LexV2CfnCr.Outputs.LexV2CfnCrFunctionArn botId: !Ref LexBot 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: !GetAtt LexV2CfnCr.Outputs.LexV2CfnCrFunctionArn botId: !Ref LexBot botAliasName: live botVersion: !Ref LexBotVersion botAliasLocaleSettings: en_US: enabled: True 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