Skip to content

create_slot_type async

create_slot_type(
    slot_type_name: Name,
    bot_id: Id,
    bot_version: DraftBotVersion,
    locale_id: LocaleId,
    *,
    config_overrides: Optional[AsyncLexModelsV2ClientConfig] = None,
    description: Optional[Description] = None,
    slot_type_values: Optional[SlotTypeValues] = None,
    value_selection_setting: Optional[SlotValueSelectionSetting] = None,
    parent_slot_type_signature: Optional[SlotTypeSignature] = None,
    external_source_setting: Optional[ExternalSourceSetting] = None,
    composite_slot_type_setting: Optional[CompositeSlotTypeSetting] = None,
) -> CreateSlotTypeResponse

Creates a custom slot type

To create a custom slot type, specify a name for the slot type and a set of enumeration values, the values that a slot of this type can assume.

Parameters:

  • slot_type_name (Name) –

    The name for the slot. A slot type name must be unique within the intent.

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

    A description of the slot type. Use the description to help identify the slot type in lists.

  • slot_type_values (Optional[SlotTypeValues], default: None ) –

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

  • value_selection_setting (Optional[SlotValueSelectionSetting], default: None ) –

    Determines the strategy that Amazon Lex uses to select a value from the list of possible 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. If there is no resolution list, return null.

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

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

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

    Only AMAZON.AlphaNumeric is supported.

  • bot_id (Id) –

    The identifier of the bot associated with this slot type.

  • bot_version (DraftBotVersion) –

    The identifier of the bot version associated with this slot type.

  • locale_id (LocaleId) –

    The identifier of the language and locale that the slot type will be used in. The string must match one of the supported locales. All of the bots, intents, and slots used by the slot type must have the same locale. For more information, see Supported languages.

  • external_source_setting (Optional[ExternalSourceSetting], default: None ) –

    Sets the type of external information used to create the slot type.

  • composite_slot_type_setting (Optional[CompositeSlotTypeSetting], default: None ) –

    Specifications for a composite slot type.

Raises:

  • ConflictException –

    The action that you tried to perform couldn't be completed because the resource is in a conflicting state. For example, deleting a bot that is in the CREATING state. Try your request again.

  • InternalServerException –

    The service encountered an unexpected condition. Try your request again.

  • PreconditionFailedException –

    Your request couldn't be completed because one or more request fields aren't valid. Check the fields in your request and try again.

  • ServiceQuotaExceededException –

    You have reached a quota for your bot.

  • ThrottlingException –

    Your request rate is too high. Reduce the frequency of requests.

  • ValidationException –

    One of the input parameters in your request isn't valid. Check the parameters and try your request again.

  • UnknownServiceError –

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

Source code in docs_src/capo_lex_models_v2/_services/async_lex_models_v2.py
async def create_slot_type(
    self,
    slot_type_name: "capo_lex_models_v2.types.name.Name",
    bot_id: "capo_lex_models_v2.types.id.Id",
    bot_version: "capo_lex_models_v2.types.draft_bot_version.DraftBotVersion",
    locale_id: "capo_lex_models_v2.types.locale_id.LocaleId",
    *,
    config_overrides: Optional[AsyncLexModelsV2ClientConfig] = None,
    description: Optional[
        "capo_lex_models_v2.types.description.Description"
    ] = None,
    slot_type_values: Optional[
        "capo_lex_models_v2.types.slot_type_values.SlotTypeValues"
    ] = None,
    value_selection_setting: Optional[
        "capo_lex_models_v2.types.slot_value_selection_setting.SlotValueSelectionSetting"
    ] = None,
    parent_slot_type_signature: Optional[
        "capo_lex_models_v2.types.slot_type_signature.SlotTypeSignature"
    ] = None,
    external_source_setting: Optional[
        "capo_lex_models_v2.types.external_source_setting.ExternalSourceSetting"
    ] = None,
    composite_slot_type_setting: Optional[
        "capo_lex_models_v2.types.composite_slot_type_setting.CompositeSlotTypeSetting"
    ] = None,
) -> "capo_lex_models_v2.types.create_slot_type_response.CreateSlotTypeResponse":
    """<p>Creates a custom slot type</p> <p> To create a custom slot type, specify a name for the slot type and a set of enumeration values, the values that a slot of this type can assume. </p>

    Args:
        slot_type_name: <p>The name for the slot. A slot type name must be unique within the intent.</p>
        description: <p>A description of the slot type. Use the description to help identify the slot type in lists.</p>
        slot_type_values: <p>A list of <code>SlotTypeValue</code> objects that defines the values that the slot type can take. Each value can have a list of synonyms, additional values that help train the machine learning model about the values that it resolves for a slot.</p>
        value_selection_setting: <p>Determines the strategy that Amazon Lex uses to select a value from the list of possible 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. If there is no resolution list, return null.</p> </li> </ul> <p>If you don't specify the <code>valueSelectionSetting</code> parameter, the default is <code>ORIGINAL_VALUE</code>.</p>
        parent_slot_type_signature: <p>The built-in slot type used as a parent of this slot type. When you define a parent slot type, the new slot type has the configuration of the parent slot type.</p> <p>Only <code>AMAZON.AlphaNumeric</code> is supported.</p>
        bot_id: <p>The identifier of the bot associated with this slot type.</p>
        bot_version: <p>The identifier of the bot version associated with this slot type.</p>
        locale_id: <p>The identifier of the language and locale that the slot type will be used in. The string must match one of the supported locales. All of the bots, intents, and slots used by the slot type must have the same locale. For more information, see <a href="https://docs.aws.amazon.com/lexv2/latest/dg/how-languages.html">Supported languages</a>.</p>
        external_source_setting: <p>Sets the type of external information used to create the slot type.</p>
        composite_slot_type_setting: <p>Specifications for a composite slot type.</p>

    Raises:
        capo_lex_models_v2.errors.conflict_exception.ConflictException: <p>The action that you tried to perform couldn't be completed because the resource is in a conflicting state. For example, deleting a bot that is in the CREATING state. Try your request again. </p>
        capo_lex_models_v2.errors.internal_server_exception.InternalServerException: <p>The service encountered an unexpected condition. Try your request again.</p>
        capo_lex_models_v2.errors.precondition_failed_exception.PreconditionFailedException: <p>Your request couldn't be completed because one or more request fields aren't valid. Check the fields in your request and try again.</p>
        capo_lex_models_v2.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>You have reached a quota for your bot. </p>
        capo_lex_models_v2.errors.throttling_exception.ThrottlingException: <p>Your request rate is too high. Reduce the frequency of requests.</p>
        capo_lex_models_v2.errors.validation_exception.ValidationException: <p>One of the input parameters in your request isn't valid. Check the parameters and try your request again.</p>
        capo_lex_models_v2.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_lex_models_v2.types.create_slot_type_request.CreateSlotTypeRequest]",
    ) -> AsyncOperationResponse[
        "capo_lex_models_v2.types.create_slot_type_response.CreateSlotTypeResponse"
    ]:
        import capo_lex_models_v2._operations.lex_model_building_service_v2.create_slot_type

        (
            output,
            http_response,
        ) = await capo_lex_models_v2._operations.lex_model_building_service_v2.create_slot_type.async_create_slot_type(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateSlotType")
    )
    input_: capo_lex_models_v2.types.create_slot_type_request.CreateSlotTypeRequest = {
        "slot_type_name": slot_type_name,
        "bot_id": bot_id,
        "bot_version": bot_version,
        "locale_id": locale_id,
    }
    if description is not None:
        input_["description"] = description
    if slot_type_values is not None:
        input_["slot_type_values"] = slot_type_values
    if value_selection_setting is not None:
        input_["value_selection_setting"] = value_selection_setting
    if parent_slot_type_signature is not None:
        input_["parent_slot_type_signature"] = parent_slot_type_signature
    if external_source_setting is not None:
        input_["external_source_setting"] = external_source_setting
    if composite_slot_type_setting is not None:
        input_["composite_slot_type_setting"] = composite_slot_type_setting

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output