Guest User

LexCFN.yaml

a guest
Aug 25th, 2022
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.87 KB | None | 0 0
  1. Parameters:
  2. LambdaFctName:
  3. Description: Lambda function
  4. Type: String
  5.  
  6. # The OrderFlower bot consists of the following:
  7. # 1. IAM role that is used by the bot at runtime
  8. # 2. Inline Bot
  9. # 3. Bot Version
  10. # 4. Alias
  11. Resources:
  12. # 1. IAM Role used by the Lex service to make runtime calls
  13. BotRuntimeRole:
  14. Type: AWS::IAM::Role
  15. Properties:
  16. AssumeRolePolicyDocument:
  17. Version: "2012-10-17"
  18. Statement:
  19. - Effect: Allow
  20. Principal:
  21. Service:
  22. - lexv2.amazonaws.com
  23. Action:
  24. - "sts:AssumeRole"
  25. Path: "/"
  26. Policies:
  27. - PolicyName: LexRuntimeRolePolicy
  28. PolicyDocument:
  29. Version: 2012-10-17
  30. Statement:
  31. - Effect: Allow
  32. Action:
  33. - "polly:SynthesizeSpeech"
  34. - "comprehend:DetectSentiment"
  35. Resource: "*"
  36.  
  37. # 2. Inline bot definition that depends on the IAM role.
  38. # The bot definition consists of combining all the child resources into one CFN resource.
  39. # This includes Locales, Intents, Slots, and SlotTypes.
  40. OrderFlowersTemplateBot:
  41. DependsOn: BotRuntimeRole
  42. Type: AWS::Lex::Bot
  43. Properties:
  44. Name: "OrderFlowersWithCFN"
  45. RoleArn: !GetAtt BotRuntimeRole.Arn
  46. DataPrivacy:
  47. ChildDirected: false
  48. IdleSessionTTLInSeconds: 300
  49. Description: "How to create a OrderFlowers bot with CFN"
  50. # We provide a setting that allows you to auto build the locales provided.
  51. # Locale builds are also kicked off if you attempt to create a bot version
  52. # that depends on an unbuilt locale.
  53. AutoBuildBotLocales: false
  54. BotLocales:
  55. - LocaleId: "en_US"
  56. Description: "Book a trip bot Locale"
  57. NluConfidenceThreshold: 0.40
  58. VoiceSettings:
  59. VoiceId: "Ivy"
  60. SlotTypes:
  61. - Name: "FlowerTypes"
  62. Description: "Slot Type description"
  63. SlotTypeValues:
  64. - SampleValue:
  65. Value: lilies
  66. - SampleValue:
  67. Value: roses
  68. - SampleValue:
  69. Value: tulips
  70. ValueSelectionSetting:
  71. ResolutionStrategy: ORIGINAL_VALUE
  72. Intents:
  73. - Name: "TestIntent"
  74. Description: "Testing Intent"
  75. SampleUtterances:
  76. - Utterance: "test"
  77. - Utterance: "debug my code hook"
  78. - Utterance: "test lambda"
  79. DialogCodeHook:
  80. Enabled: true
  81. - Name: "OrderFlowers"
  82. Description: "Intent to order a bouquet of flowers for pick up"
  83. SampleUtterances:
  84. - Utterance: "I would like to pick up flowers"
  85. - Utterance: "I would like to order some flowers"
  86. IntentConfirmationSetting:
  87. PromptSpecification:
  88. MessageGroupsList:
  89. - Message:
  90. PlainTextMessage:
  91. Value: "Okay, your {FlowerType} will be ready for pickup by {PickupTime} on {PickupDate}. Does this sound okay?"
  92. MaxRetries: 3
  93. AllowInterrupt: false
  94. DeclinationResponse:
  95. MessageGroupsList:
  96. - Message:
  97. PlainTextMessage:
  98. Value: "Okay, I will not place your order."
  99. AllowInterrupt: false
  100. SlotPriorities:
  101. - Priority: 2
  102. SlotName: PickupDate
  103. - Priority: 1
  104. SlotName: FlowerType
  105. - Priority: 3
  106. SlotName: PickupTime
  107. Slots:
  108. - Name: "FlowerType"
  109. Description: "something"
  110. SlotTypeName: "FlowerTypes"
  111. ValueElicitationSetting:
  112. SlotConstraint: "Required"
  113. PromptSpecification:
  114. MessageGroupsList:
  115. - Message:
  116. PlainTextMessage:
  117. Value: "What type of flowers would you like to order?"
  118. MaxRetries: 3
  119. AllowInterrupt: false
  120. - Name: "PickupDate"
  121. Description: "something"
  122. SlotTypeName: "AMAZON.Date"
  123. ValueElicitationSetting:
  124. SlotConstraint: "Required"
  125. PromptSpecification:
  126. MessageGroupsList:
  127. - Message:
  128. PlainTextMessage:
  129. Value: "What day do you want the {FlowerType} to be picked up?"
  130. MaxRetries: 3
  131. AllowInterrupt: false
  132. - Name: "PickupTime"
  133. Description: "something"
  134. SlotTypeName: "AMAZON.Time"
  135. ValueElicitationSetting:
  136. SlotConstraint: "Required"
  137. PromptSpecification:
  138. MessageGroupsList:
  139. - Message:
  140. PlainTextMessage:
  141. Value: "At what time do you want the {FlowerType} to be picked up?"
  142. MaxRetries: 3
  143. AllowInterrupt: false
  144. - Name: "FallbackIntent"
  145. Description: "Default intent when no other intent matches"
  146. ParentIntentSignature: "AMAZON.FallbackIntent"
  147.  
  148. # 3. Define a bot version that depends on the DRAFT version of the Lex Bot.
  149. OrderFlowersTemplateBotVersionWithCFN:
  150. DependsOn: OrderFlowersTemplateBot
  151. Type: AWS::Lex::BotVersion
  152. Properties:
  153. BotId: !Ref OrderFlowersTemplateBot
  154. BotVersionLocaleSpecification:
  155. - LocaleId: en_US
  156. BotVersionLocaleDetails:
  157. SourceBotVersion: DRAFT
  158. Description: OrderFlowers Version
  159.  
  160. # 4. Define the alias by providing the bot version created by the
  161. # AWS::Lex::BotVersion resource above.
  162. FirstBotAliasWithCFN:
  163. DependsOn: OrderFlowersTemplateBotVersionWithCFN
  164. Type: AWS::Lex::BotAlias
  165. Properties:
  166. BotId: !Ref OrderFlowersTemplateBot
  167. BotAliasName: "OrderFlowersVersion1Alias"
  168. BotVersion: !GetAtt OrderFlowersTemplateBotVersionWithCFN.BotVersion
  169. BotAliasLocaleSettings:
  170. - BotAliasLocaleSetting:
  171. CodeHookSpecification:
  172. LambdaCodeHook:
  173. CodeHookInterfaceVersion: "1.0"
  174. LambdaArn: !Sub "arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${LambdaFctName}"
  175. Enabled: true
  176. LocaleId: en_US
  177. SentimentAnalysisSettings:
  178. DetectSentiment: true
Add Comment
Please, Sign In to add comment