Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AWSTemplateFormatVersion: "2010-09-09"
- Transform: AWS::Serverless-2016-10-31
- Description: >
- ReHub Bot - Work in progress
- Resources:
- BotRuntimeRole:
- Type: AWS::IAM::Role
- Properties:
- AssumeRolePolicyDocument:
- Version: "2012-10-17"
- Statement:
- - Effect: Allow
- Principal:
- Service:
- - lexv2.amazonaws.com
- Action:
- - "sts:AssumeRole"
- Path: "/"
- Policies:
- - PolicyName: LexRuntimeRolePolicy
- PolicyDocument:
- Version: 2012-10-17
- Statement:
- - Effect: Allow
- Action:
- - "polly:SynthesizeSpeech"
- - "comprehend:DetectSentiment"
- Resource: "*"
- - PolicyName: LexRunLambdaPolicy
- PolicyDocument:
- Version: 2012-10-17
- Statement:
- - Effect: Allow
- Action:
- - "lambda:InvokeFunction"
- Resource: "*"
- ReHubBot:
- DependsOn: BotRuntimeRole
- Type: AWS::Lex::Bot
- Properties:
- Name: "ReHubBot"
- RoleArn: !GetAtt BotRuntimeRole.Arn
- DataPrivacy:
- ChildDirected: false
- IdleSessionTTLInSeconds: 300
- Description: "Provides voice control to the ReHub app."
- AutoBuildBotLocales: true
- BotLocales:
- - LocaleId: "es_ES"
- Description: "¿Qué quieres hacer?"
- NluConfidenceThreshold: 0.40
- VoiceSettings:
- VoiceId: "Lucia"
- SlotTypes:
- - Name: "ExerciceValues"
- Description: "Nombres de ejercicio"
- SlotTypeValues:
- - SampleValue:
- Value: "hombro"
- - SampleValue:
- Value: "brazo"
- - SampleValue:
- Value: "mano"
- ValueSelectionSetting:
- ResolutionStrategy: ORIGINAL_VALUE
- Intents:
- - Name: "Iniciar"
- Description: "Iniciar"
- SampleUtterances:
- - Utterance: "Iniciar"
- - Utterance: "Iniciar el ejercicio"
- - Utterance: "Quiero iniciar el ejercicio"
- Slots:
- - Name: "ExerciceId"
- Description: "something"
- SlotTypeName: "ExerciceValues"
- ValueElicitationSetting:
- SlotConstraint: "Required"
- PromptSpecification:
- MessageGroupsList:
- - Message:
- PlainTextMessage:
- Value: "Indica el ejercicio"
- MaxRetries: 3
- AllowInterrupt: false
- SlotPriorities:
- - Priority: 1
- SlotName: ExerciceId
- IntentConfirmationSetting:
- PromptSpecification:
- MessageGroupsList:
- - Message:
- PlainTextMessage:
- Value: "Ok, quieres iniciar el ejercicio {ExerciceId}. ¿Es correcto?"
- MaxRetries: 3
- AllowInterrupt: false
- DeclinationResponse:
- MessageGroupsList:
- - Message:
- PlainTextMessage:
- Value: "Ok, He cancelado la acción."
- AllowInterrupt: false
- FulfillmentCodeHook:
- Enabled: true
- PostFulfillmentStatusSpecification:
- FailureResponse:
- MessageGroupsList:
- - Message:
- PlainTextMessage:
- Value: "Esto es FailureResponse"
- AllowInterrupt: false
- SuccessResponse:
- MessageGroupsList:
- - Message:
- PlainTextMessage:
- Value: "Esto es SuccessResponse"
- AllowInterrupt: false
- TimeoutResponse:
- MessageGroupsList:
- - Message:
- PlainTextMessage:
- Value: "Esto es TimeoutResponse"
- AllowInterrupt: false
- - Name: "FallbackIntent"
- Description: "Default intent when no other intent matches"
- ParentIntentSignature: "AMAZON.FallbackIntent"
- ReHubBotVersion:
- DependsOn: ReHubBot
- Type: AWS::Lex::BotVersion
- Properties:
- BotId: !Ref ReHubBot
- BotVersionLocaleSpecification:
- - LocaleId: es_ES
- BotVersionLocaleDetails:
- SourceBotVersion: DRAFT
- Description: ReHubBot Version
- ReHubBotAlias:
- DependsOn: ReHubBotVersion
- Type: AWS::Lex::BotAlias
- Properties:
- BotId: !Ref ReHubBot
- BotAliasName: "Prod"
- BotVersion: !GetAtt ReHubBotVersion.BotVersion
- SentimentAnalysisSettings:
- DetectSentiment: false
- BotAliasLocaleSettings:
- - LocaleId: es_ES
- BotAliasLocaleSetting:
- Enabled: true
- CodeHookSpecification:
- LambdaCodeHook:
- CodeHookInterfaceVersion: "1.0"
- LambdaArn: !GetAtt TestLexFunction.Arn
- LexInvokeLambdaPermission:
- Type: AWS::Lambda::Permission
- Properties:
- Action: "lambda:InvokeFunction"
- FunctionName: !GetAtt TestLexFunction.Arn
- Principal: "lexv2.amazonaws.com"
- SourceArn: !GetAtt ReHubBotAlias.Arn
- TestLexFunction:
- Type: AWS::Lambda::Function
- Properties:
- FunctionName: !Sub ${AWS::StackName}-TestLex
- Code:
- ZipFile: |
- import logging
- logger = logging.getLogger()
- logger.setLevel(logging.DEBUG)
- def lambda_handler(event, context):
- logger.debug(event)
- Handler: index.lambda_handler
- Role: !GetAtt LambdaRole.Arn
- Runtime: python3.9
- MemorySize: 128
- Timeout: 300
- LambdaRole:
- Type: "AWS::IAM::Role"
- Properties:
- AssumeRolePolicyDocument:
- Version: 2012-10-17
- Statement:
- - Effect: Allow
- Principal:
- Service:
- - lambda.amazonaws.com
- Action:
- - "sts:AssumeRole"
- ManagedPolicyArns:
- - arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
- Path: /
Add Comment
Please, Sign In to add comment