Skip to content

create_slot

create_slot(
    slot_name: Name,
    value_elicitation_setting: SlotValueElicitationSetting,
    bot_id: Id,
    bot_version: DraftBotVersion,
    locale_id: LocaleId,
    intent_id: Id,
    *,
    config_overrides: Optional[LexModelsV2ClientConfig] = None,
    description: Optional[Description] = None,
    slot_type_id: Optional[BuiltInOrCustomSlotTypeId] = None,
    obfuscation_setting: Optional[ObfuscationSetting] = None,
    multiple_values_setting: Optional[MultipleValuesSetting] = None,
    sub_slot_setting: Optional[SubSlotSetting] = None,
) -> CreateSlotResponse

Creates a slot in an intent. A slot is a variable needed to fulfill an intent. For example, an OrderPizza intent might need slots for size, crust, and number of pizzas. For each slot, you define one or more utterances that Amazon Lex uses to elicit a response from the user.

Parameters:

  • slot_name (Name) –

    The name of the slot. Slot names must be unique within the bot that contains the slot.

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

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

  • slot_type_id (Optional[BuiltInOrCustomSlotTypeId], default: None ) –

    The unique identifier for the slot type associated with this slot. The slot type determines the values that can be entered into the slot.

  • value_elicitation_setting (SlotValueElicitationSetting) –

    Specifies prompts that Amazon Lex sends to the user to elicit a response that provides the value for the slot.

  • obfuscation_setting (Optional[ObfuscationSetting], default: None ) –

    Determines how slot values are used in Amazon CloudWatch logs. If the value of the obfuscationSetting parameter is DefaultObfuscation, slot values are obfuscated in the log output. If the value is None, the actual value is present in the log output.

    The default is to obfuscate values in the CloudWatch logs.

  • bot_id (Id) –

    The identifier of the bot associated with the slot.

  • bot_version (DraftBotVersion) –

    The version of the bot associated with the slot.

  • locale_id (LocaleId) –

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

  • intent_id (Id) –

    The identifier of the intent that contains the slot.

  • multiple_values_setting (Optional[MultipleValuesSetting], default: None ) –

    Indicates whether the slot returns multiple values in one response. Multi-value slots are only available in the en-US locale. If you set this value to true in any other locale, Amazon Lex throws a ValidationException.

    If the multipleValuesSetting is not set, the default value is false.

  • sub_slot_setting (Optional[SubSlotSetting], default: None ) –

    Specifications for the constituent sub slots and the expression for the composite slot.

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/lex_models_v2.py
def create_slot(
    self,
    slot_name: "capo_lex_models_v2.types.name.Name",
    value_elicitation_setting: "capo_lex_models_v2.types.slot_value_elicitation_setting.SlotValueElicitationSetting",
    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",
    intent_id: "capo_lex_models_v2.types.id.Id",
    *,
    config_overrides: Optional[LexModelsV2ClientConfig] = None,
    description: Optional[
        "capo_lex_models_v2.types.description.Description"
    ] = None,
    slot_type_id: Optional[
        "capo_lex_models_v2.types.built_in_or_custom_slot_type_id.BuiltInOrCustomSlotTypeId"
    ] = None,
    obfuscation_setting: Optional[
        "capo_lex_models_v2.types.obfuscation_setting.ObfuscationSetting"
    ] = None,
    multiple_values_setting: Optional[
        "capo_lex_models_v2.types.multiple_values_setting.MultipleValuesSetting"
    ] = None,
    sub_slot_setting: Optional[
        "capo_lex_models_v2.types.sub_slot_setting.SubSlotSetting"
    ] = None,
) -> "capo_lex_models_v2.types.create_slot_response.CreateSlotResponse":
    """<p>Creates a slot in an intent. A slot is a variable needed to fulfill an intent. For example, an <code>OrderPizza</code> intent might need slots for size, crust, and number of pizzas. For each slot, you define one or more utterances that Amazon Lex uses to elicit a response from the user. </p>

    Args:
        slot_name: <p>The name of the slot. Slot names must be unique within the bot that contains the slot.</p>
        description: <p>A description of the slot. Use this to help identify the slot in lists.</p>
        slot_type_id: <p>The unique identifier for the slot type associated with this slot. The slot type determines the values that can be entered into the slot.</p>
        value_elicitation_setting: <p>Specifies prompts that Amazon Lex sends to the user to elicit a response that provides the value for the slot. </p>
        obfuscation_setting: <p>Determines how slot values are used in Amazon CloudWatch logs. If the value of the <code>obfuscationSetting</code> parameter is <code>DefaultObfuscation</code>, slot values are obfuscated in the log output. If the value is <code>None</code>, the actual value is present in the log output.</p> <p>The default is to obfuscate values in the CloudWatch logs.</p>
        bot_id: <p>The identifier of the bot associated with the slot.</p>
        bot_version: <p>The version of the bot associated with the slot.</p>
        locale_id: <p>The identifier of the language and locale that the slot will be used in. The string must match one of the supported locales. All of the bots, intents, slot types used by the slot 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>
        intent_id: <p>The identifier of the intent that contains the slot.</p>
        multiple_values_setting: <p>Indicates whether the slot returns multiple values in one response. Multi-value slots are only available in the <code>en-US</code> locale. If you set this value to <code>true</code> in any other locale, Amazon Lex throws a <code>ValidationException</code>. </p> <p>If the <code>multipleValuesSetting</code> is not set, the default value is <code>false</code>.</p>
        sub_slot_setting: <p>Specifications for the constituent sub slots and the expression for the composite slot.</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.
    """

    def _handler(
        req: "OperationRequest[capo_lex_models_v2.types.create_slot_request.CreateSlotRequest]",
    ) -> OperationResponse[
        "capo_lex_models_v2.types.create_slot_response.CreateSlotResponse"
    ]:
        import capo_lex_models_v2._operations.lex_model_building_service_v2.create_slot

        output, http_response = (
            capo_lex_models_v2._operations.lex_model_building_service_v2.create_slot.create_slot(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateSlot")
    )
    input_: capo_lex_models_v2.types.create_slot_request.CreateSlotRequest = {
        "slot_name": slot_name,
        "value_elicitation_setting": value_elicitation_setting,
        "bot_id": bot_id,
        "bot_version": bot_version,
        "locale_id": locale_id,
        "intent_id": intent_id,
    }
    if description is not None:
        input_["description"] = description
    if slot_type_id is not None:
        input_["slot_type_id"] = slot_type_id
    if obfuscation_setting is not None:
        input_["obfuscation_setting"] = obfuscation_setting
    if multiple_values_setting is not None:
        input_["multiple_values_setting"] = multiple_values_setting
    if sub_slot_setting is not None:
        input_["sub_slot_setting"] = sub_slot_setting

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