Multiple value slot in Cloudformation for Amazon Lex V2

271 Views Asked by At

I'm building a bot that needs to catch multiple users mentions (I'm building this using a CloudFormation template). For that I use a slot, but this slot needs to store one or more usernames. According to documentation, there are three requisites to do that:

  • Slot type must be custom type.
  • Slot must be declared under en_US locale.
  • Slot must be defined to AllowMultipleValues.

So, I tried this:

# [...]
Resources:
  MyBot:
    Type: AWS::Lex::Bot
    Properties:
      # [...]
      BotLocales:
        - LocaleId: "en_US"
          # [...]
          SlotTypes:
            # [...]
            - Name: !Sub "user_${env}"
              Description: "..."
              ValueSelectionSetting:
                ResolutionStrategy: ORIGINAL_VALUE
                RegexFilter:
                  Pattern: "@?\\w{1,100}"
          Intents:
            # [...]
            - Name: !Sub "AnIntent_${env}"
              Description: "Intent that does what I need"
              SampleUtterances:
                # [...]
              # [...]
              SlotPriorities:
                - Priority: 1
                  SlotName: user
              FulfillmentCodeHook:
                Enabled: true
                IsActive: true    
              Slots:
                - Name: "user"
                  Description: "..."
                  SlotTypeName: !Sub "user_${env}"
                  MultipleValuesSetting:
                    AllowMultipleValues: true
                  ValueElicitationSetting:
                    SlotConstraint: "Required"
                    PromptSpecification:
                      MessageGroupsList:
                        - Message:
                            PlainTextMessage:
                              Value: "..."
                      MaxRetries: 3
                      AllowInterrupt: false

As you can see, I'm declaring a custom slot type and then referencing it into my only Intent through its name in SlotTypeName property of my Slots section. So, at first sigh, requisites are ok: custom slot type, declared for en_US locale and multi value allowed.

When I try to deploy these changes, I get the following message:

Resource handler returned message: "Importing MyBot failed due to [Couldn't import the bot. SlotTypeConfiguration and CustomSlotTypeDefinition both cannot be specified together. Validation error occurred at Slot Type user_dev for Locale en_US. Check the value and try your request again.]. The import could not be completed." (RequestToken: [...], HandlerErrorCode: InvalidRequest)

I also tried by configuring ParentSlotTypeSignature: "AMAZON.AlphaNumeric" in the SlotType definition. In this case the error message tells me that AllowMultipleValues is not allowed for AMAZON.AlphaNumeric SlotType.

Seems the error is at SlotType definition but I'm not able to find it. So, could anyone help to identify what I'm doing wrong?

Thanks in advance!

0

There are 0 best solutions below