Skip to content

put_slot_type

put_slot_type(
    name: SlotTypeName,
    *,
    config_overrides: Optional[LexModelBuildingServiceClientConfig] = None,
    description: Optional[Description] = None,
    enumeration_values: Optional[EnumerationValues] = None,
    checksum: Optional[String] = None,
    value_selection_strategy: Optional[SlotValueSelectionStrategy] = None,
    create_version: Optional[Boolean] = None,
    parent_slot_type_signature: Optional[CustomOrBuiltinSlotTypeName] = None,
    slot_type_configurations: Optional[SlotTypeConfigurations] = None,
) -> PutSlotTypeResponse

Creates a custom slot type or replaces an existing custom slot type.

To create a custom slot type, specify a name for the slot type and a set of enumeration values, which are the values that a slot of this type can assume. For more information, see how-it-works.

If you specify the name of an existing slot type, the fields in the request replace the existing values in the $LATEST version of the slot type. Amazon Lex removes the fields that you don't provide in the request. If you don't specify required fields, Amazon Lex throws an exception. When you update the $LATEST version of a slot type, if a bot uses the $LATEST version of an intent that contains the slot type, the bot's status field is set to NOT_BUILT.

This operation requires permissions for the lex:PutSlotType action.

Parameters:

  • name (SlotTypeName) –

    The name of the slot type. The name is not case sensitive.

    The name can't match a built-in slot type name, or a built-in slot type name with "AMAZON." removed. For example, because there is a built-in slot type called AMAZON.DATE, you can't create a custom slot type called DATE.

    For a list of built-in slot types, see Slot Type Reference in the Alexa Skills Kit.

  • description (Optional[Description], default: None ) –

    A description of the slot type.

  • enumeration_values (Optional[EnumerationValues], default: None ) –

    A list of EnumerationValue objects that defines the values that the slot type can take. Each value can have a list of synonyms, which are additional values that help train the machine learning model about the values that it resolves for a slot.

    A regular expression slot type doesn't require enumeration values. All other slot types require a list of enumeration values.

    When Amazon Lex resolves a slot value, it generates a resolution list that contains up to five possible values for the slot. If you are using a Lambda function, this resolution list is passed to the function. If you are not using a Lambda function you can choose to return the value that the user entered or the first value in the resolution list as the slot value. The valueSelectionStrategy field indicates the option to use.

  • checksum (Optional[String], default: None ) –

    Identifies a specific revision of the $LATEST version.

    When you create a new slot type, leave the checksum field blank. If you specify a checksum you get a BadRequestException exception.

    When you want to update a slot type, set the checksum field to the checksum of the most recent revision of the $LATEST version. If you don't specify the checksum field, or if the checksum does not match the $LATEST version, you get a PreconditionFailedException exception.

  • value_selection_strategy (Optional[SlotValueSelectionStrategy], default: None ) –

    Determines the slot resolution strategy that Amazon Lex uses to return slot type values. The field can be set to one of the following values:

    • ORIGINAL_VALUE - Returns the value entered by the user, if the user value is similar to the slot value.

    • TOP_RESOLUTION - If there is a resolution list for the slot, return the first value in the resolution list as the slot type value. If there is no resolution list, null is returned.

    If you don't specify the valueSelectionStrategy, the default is ORIGINAL_VALUE.

  • create_version (Optional[Boolean], default: None ) –

    When set to true a new numbered version of the slot type is created. This is the same as calling the CreateSlotTypeVersion operation. If you do not specify createVersion, the default is false.

  • parent_slot_type_signature (Optional[CustomOrBuiltinSlotTypeName], default: None ) –

    The built-in slot type used as the parent of the slot type. When you define a parent slot type, the new slot type has all of the same configuration as the parent.

    Only AMAZON.AlphaNumeric is supported.

  • slot_type_configurations (Optional[SlotTypeConfigurations], default: None ) –

    Configuration information that extends the parent built-in slot type. The configuration is added to the settings for the parent slot type.

Raises:

  • BadRequestException –

    The request is not well formed. For example, a value is invalid or a required field is missing. Check the field values, and try again.

  • ConflictException –

    There was a conflict processing the request. Try your request again.

  • InternalFailureException –

    An internal Amazon Lex error occurred. Try your request again.

  • LimitExceededException –

    The request exceeded a limit. Try your request again.

  • PreconditionFailedException –

    The checksum of the resource that you are trying to change does not match the checksum in the request. Check the resource's checksum and try again.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Examples:

To Create a Slot Type This example shows how to create a slot type that describes pizza sauces.

>>> client.put_slot_type(name='PizzaSauceType', description='Available pizza sauces', enumeration_values=[{'value': 'red'}, {'value': 'white'}])
Source code in docs_src/capo_lex_model_building_service/_services/lex_model_building_service.py
def put_slot_type(
    self,
    name: "capo_lex_model_building_service.types.slot_type_name.SlotTypeName",
    *,
    config_overrides: Optional[LexModelBuildingServiceClientConfig] = None,
    description: Optional[
        "capo_lex_model_building_service.types.description.Description"
    ] = None,
    enumeration_values: Optional[
        "capo_lex_model_building_service.types.enumeration_values.EnumerationValues"
    ] = None,
    checksum: Optional[
        "capo_lex_model_building_service.types.string.String"
    ] = None,
    value_selection_strategy: Optional[
        "capo_lex_model_building_service.types.slot_value_selection_strategy.SlotValueSelectionStrategy"
    ] = None,
    create_version: Optional[
        "capo_lex_model_building_service.types.boolean.Boolean"
    ] = None,
    parent_slot_type_signature: Optional[
        "capo_lex_model_building_service.types.custom_or_builtin_slot_type_name.CustomOrBuiltinSlotTypeName"
    ] = None,
    slot_type_configurations: Optional[
        "capo_lex_model_building_service.types.slot_type_configurations.SlotTypeConfigurations"
    ] = None,
) -> "capo_lex_model_building_service.types.put_slot_type_response.PutSlotTypeResponse":
    """<p>Creates a custom slot type or replaces an existing custom slot type.</p> <p>To create a custom slot type, specify a name for the slot type and a set of enumeration values, which are the values that a slot of this type can assume. For more information, see <a>how-it-works</a>.</p> <p>If you specify the name of an existing slot type, the fields in the request replace the existing values in the <code>$LATEST</code> version of the slot type. Amazon Lex removes the fields that you don't provide in the request. If you don't specify required fields, Amazon Lex throws an exception. When you update the <code>$LATEST</code> version of a slot type, if a bot uses the <code>$LATEST</code> version of an intent that contains the slot type, the bot's <code>status</code> field is set to <code>NOT_BUILT</code>.</p> <p>This operation requires permissions for the <code>lex:PutSlotType</code> action.</p>

    Args:
        name: <p>The name of the slot type. The name is <i>not</i> case sensitive. </p> <p>The name can't match a built-in slot type name, or a built-in slot type name with "AMAZON." removed. For example, because there is a built-in slot type called <code>AMAZON.DATE</code>, you can't create a custom slot type called <code>DATE</code>.</p> <p>For a list of built-in slot types, see <a href="https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/built-in-intent-ref/slot-type-reference">Slot Type Reference</a> in the <i>Alexa Skills Kit</i>.</p>
        description: <p>A description of the slot type.</p>
        enumeration_values: <p>A list of <code>EnumerationValue</code> objects that defines the values that the slot type can take. Each value can have a list of <code>synonyms</code>, which are additional values that help train the machine learning model about the values that it resolves for a slot. </p> <p>A regular expression slot type doesn't require enumeration values. All other slot types require a list of enumeration values.</p> <p>When Amazon Lex resolves a slot value, it generates a resolution list that contains up to five possible values for the slot. If you are using a Lambda function, this resolution list is passed to the function. If you are not using a Lambda function you can choose to return the value that the user entered or the first value in the resolution list as the slot value. The <code>valueSelectionStrategy</code> field indicates the option to use. </p>
        checksum: <p>Identifies a specific revision of the <code>$LATEST</code> version.</p> <p>When you create a new slot type, leave the <code>checksum</code> field blank. If you specify a checksum you get a <code>BadRequestException</code> exception.</p> <p>When you want to update a slot type, set the <code>checksum</code> field to the checksum of the most recent revision of the <code>$LATEST</code> version. If you don't specify the <code> checksum</code> field, or if the checksum does not match the <code>$LATEST</code> version, you get a <code>PreconditionFailedException</code> exception.</p>
        value_selection_strategy: <p>Determines the slot resolution strategy that Amazon Lex uses to return slot type values. The field can be set to one of the following values:</p> <ul> <li> <p> <code>ORIGINAL_VALUE</code> - Returns the value entered by the user, if the user value is similar to the slot value.</p> </li> <li> <p> <code>TOP_RESOLUTION</code> - If there is a resolution list for the slot, return the first value in the resolution list as the slot type value. If there is no resolution list, null is returned.</p> </li> </ul> <p>If you don't specify the <code>valueSelectionStrategy</code>, the default is <code>ORIGINAL_VALUE</code>.</p>
        create_version: <p>When set to <code>true</code> a new numbered version of the slot type is created. This is the same as calling the <code>CreateSlotTypeVersion</code> operation. If you do not specify <code>createVersion</code>, the default is <code>false</code>.</p>
        parent_slot_type_signature: <p>The built-in slot type used as the parent of the slot type. When you define a parent slot type, the new slot type has all of the same configuration as the parent.</p> <p>Only <code>AMAZON.AlphaNumeric</code> is supported.</p>
        slot_type_configurations: <p>Configuration information that extends the parent built-in slot type. The configuration is added to the settings for the parent slot type.</p>

    Raises:
        capo_lex_model_building_service.errors.bad_request_exception.BadRequestException: <p>The request is not well formed. For example, a value is invalid or a required field is missing. Check the field values, and try again.</p>
        capo_lex_model_building_service.errors.conflict_exception.ConflictException: <p> There was a conflict processing the request. Try your request again. </p>
        capo_lex_model_building_service.errors.internal_failure_exception.InternalFailureException: <p>An internal Amazon Lex error occurred. Try your request again.</p>
        capo_lex_model_building_service.errors.limit_exceeded_exception.LimitExceededException: <p>The request exceeded a limit. Try your request again.</p>
        capo_lex_model_building_service.errors.precondition_failed_exception.PreconditionFailedException: <p> The checksum of the resource that you are trying to change does not match the checksum in the request. Check the resource's checksum and try again.</p>
        capo_lex_model_building_service.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To Create a Slot Type
        This example shows how to create a slot type that describes pizza sauces.

        >>> client.put_slot_type(name='PizzaSauceType', description='Available pizza sauces', enumeration_values=[{'value': 'red'}, {'value': 'white'}])
    """

    def _handler(
        req: "OperationRequest[capo_lex_model_building_service.types.put_slot_type_request.PutSlotTypeRequest]",
    ) -> OperationResponse[
        "capo_lex_model_building_service.types.put_slot_type_response.PutSlotTypeResponse"
    ]:
        import capo_lex_model_building_service._operations.aws_deep_sense_model_building_service.put_slot_type

        output, http_response = (
            capo_lex_model_building_service._operations.aws_deep_sense_model_building_service.put_slot_type.put_slot_type(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("PutSlotType")
    )
    input_: capo_lex_model_building_service.types.put_slot_type_request.PutSlotTypeRequest = {
        "name": name
    }
    if description is not None:
        input_["description"] = description
    if enumeration_values is not None:
        input_["enumeration_values"] = enumeration_values
    if checksum is not None:
        input_["checksum"] = checksum
    if value_selection_strategy is not None:
        input_["value_selection_strategy"] = value_selection_strategy
    if create_version is not None:
        input_["create_version"] = create_version
    if parent_slot_type_signature is not None:
        input_["parent_slot_type_signature"] = parent_slot_type_signature
    if slot_type_configurations is not None:
        input_["slot_type_configurations"] = slot_type_configurations

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output