Skip to content

create_bot_locale

create_bot_locale(
    bot_id: Id,
    bot_version: DraftBotVersion,
    locale_id: LocaleId,
    nlu_intent_confidence_threshold: ConfidenceThreshold,
    *,
    config_overrides: Optional[LexModelsV2ClientConfig] = None,
    description: Optional[Description] = None,
    voice_settings: Optional[VoiceSettings] = None,
    unified_speech_settings: Optional[UnifiedSpeechSettings] = None,
    audio_filler_settings: Optional[AudioFillerSettings] = None,
    speech_recognition_settings: Optional[SpeechRecognitionSettings] = None,
    generative_ai_settings: Optional[GenerativeAISettings] = None,
    speech_detection_sensitivity: Optional[SpeechDetectionSensitivity] = None,
    speaker_diarization_settings: Optional[SpeakerDiarizationSettings] = None,
) -> CreateBotLocaleResponse

Creates a locale in the bot. The locale contains the intents and slot types that the bot uses in conversations with users in the specified language and locale. You must add a locale to a bot before you can add intents and slot types to the bot.

Parameters:

  • bot_id (Id) –

    The identifier of the bot to create the locale for.

  • bot_version (DraftBotVersion) –

    The version of the bot to create the locale for. This can only be the draft version of the bot.

  • locale_id (LocaleId) –

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

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

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

  • nlu_intent_confidence_threshold (ConfidenceThreshold) –

    Determines the threshold where Amazon Lex will insert the AMAZON.FallbackIntent, AMAZON.KendraSearchIntent, or both when returning alternative intents. AMAZON.FallbackIntent and AMAZON.KendraSearchIntent are only inserted if they are configured for the bot.

    For example, suppose a bot is configured with the confidence threshold of 0.80 and the AMAZON.FallbackIntent. Amazon Lex returns three alternative intents with the following confidence scores: IntentA (0.70), IntentB (0.60), IntentC (0.50). The response from the RecognizeText operation would be:

    • AMAZON.FallbackIntent

    • IntentA

    • IntentB

    • IntentC

  • voice_settings (Optional[VoiceSettings], default: None ) –

    The Amazon Polly voice ID that Amazon Lex uses for voice interaction with the user.

  • unified_speech_settings (Optional[UnifiedSpeechSettings], default: None ) –

    Unified speech settings to configure for the new bot locale.

  • audio_filler_settings (Optional[AudioFillerSettings], default: None ) –

    Audio filler settings to configure for the new bot locale. When enabled, Amazon Lex plays a brief background audio filler during speech-to-speech interactions to mask processing delays. Requires unifiedSpeechSettings (speech-to-speech) to be configured on the bot locale.

  • speech_recognition_settings (Optional[SpeechRecognitionSettings], default: None ) –

    Speech-to-text settings to configure for the new bot locale.

  • speech_detection_sensitivity (Optional[SpeechDetectionSensitivity], default: None ) –

    The sensitivity level for voice activity detection (VAD) in the bot locale. This setting helps optimize speech recognition accuracy by adjusting how the system responds to background noise during voice interactions.

  • speaker_diarization_settings (Optional[SpeakerDiarizationSettings], default: None ) –

    The speaker diarization settings to configure for the new bot locale. When enabled, Amazon Lex restricts speech detection to the primary (loudest) speaker during streaming audio conversations.

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_bot_locale(
    self,
    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",
    nlu_intent_confidence_threshold: "capo_lex_models_v2.types.confidence_threshold.ConfidenceThreshold",
    *,
    config_overrides: Optional[LexModelsV2ClientConfig] = None,
    description: Optional[
        "capo_lex_models_v2.types.description.Description"
    ] = None,
    voice_settings: Optional[
        "capo_lex_models_v2.types.voice_settings.VoiceSettings"
    ] = None,
    unified_speech_settings: Optional[
        "capo_lex_models_v2.types.unified_speech_settings.UnifiedSpeechSettings"
    ] = None,
    audio_filler_settings: Optional[
        "capo_lex_models_v2.types.audio_filler_settings.AudioFillerSettings"
    ] = None,
    speech_recognition_settings: Optional[
        "capo_lex_models_v2.types.speech_recognition_settings.SpeechRecognitionSettings"
    ] = None,
    generative_ai_settings: Optional[
        "capo_lex_models_v2.types.generative_ai_settings.GenerativeAISettings"
    ] = None,
    speech_detection_sensitivity: Optional[
        "capo_lex_models_v2.types.speech_detection_sensitivity.SpeechDetectionSensitivity"
    ] = None,
    speaker_diarization_settings: Optional[
        "capo_lex_models_v2.types.speaker_diarization_settings.SpeakerDiarizationSettings"
    ] = None,
) -> "capo_lex_models_v2.types.create_bot_locale_response.CreateBotLocaleResponse":
    """<p>Creates a locale in the bot. The locale contains the intents and slot types that the bot uses in conversations with users in the specified language and locale. You must add a locale to a bot before you can add intents and slot types to the bot.</p>

    Args:
        bot_id: <p>The identifier of the bot to create the locale for.</p>
        bot_version: <p>The version of the bot to create the locale for. This can only be the draft version of the bot.</p>
        locale_id: <p>The identifier of the language and locale that the bot will be used in. The string must match one of the supported locales. All of the intents, slot types, and slots used in the bot 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>
        description: <p>A description of the bot locale. Use this to help identify the bot locale in lists.</p>
        nlu_intent_confidence_threshold: <p>Determines the threshold where Amazon Lex will insert the <code>AMAZON.FallbackIntent</code>, <code>AMAZON.KendraSearchIntent</code>, or both when returning alternative intents. <code>AMAZON.FallbackIntent</code> and <code>AMAZON.KendraSearchIntent</code> are only inserted if they are configured for the bot.</p> <p>For example, suppose a bot is configured with the confidence threshold of 0.80 and the <code>AMAZON.FallbackIntent</code>. Amazon Lex returns three alternative intents with the following confidence scores: IntentA (0.70), IntentB (0.60), IntentC (0.50). The response from the <code>RecognizeText</code> operation would be:</p> <ul> <li> <p>AMAZON.FallbackIntent</p> </li> <li> <p>IntentA</p> </li> <li> <p>IntentB</p> </li> <li> <p>IntentC</p> </li> </ul>
        voice_settings: <p>The Amazon Polly voice ID that Amazon Lex uses for voice interaction with the user.</p>
        unified_speech_settings: <p>Unified speech settings to configure for the new bot locale.</p>
        audio_filler_settings: <p>Audio filler settings to configure for the new bot locale. When enabled, Amazon Lex plays a brief background audio filler during speech-to-speech interactions to mask processing delays. Requires <code>unifiedSpeechSettings</code> (speech-to-speech) to be configured on the bot locale.</p>
        speech_recognition_settings: <p>Speech-to-text settings to configure for the new bot locale.</p>
        speech_detection_sensitivity: <p>The sensitivity level for voice activity detection (VAD) in the bot locale. This setting helps optimize speech recognition accuracy by adjusting how the system responds to background noise during voice interactions.</p>
        speaker_diarization_settings: <p>The speaker diarization settings to configure for the new bot locale. When enabled, Amazon Lex restricts speech detection to the primary (loudest) speaker during streaming audio conversations.</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_bot_locale_request.CreateBotLocaleRequest]",
    ) -> OperationResponse[
        "capo_lex_models_v2.types.create_bot_locale_response.CreateBotLocaleResponse"
    ]:
        import capo_lex_models_v2._operations.lex_model_building_service_v2.create_bot_locale

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateBotLocale")
    )
    input_: capo_lex_models_v2.types.create_bot_locale_request.CreateBotLocaleRequest = {
        "bot_id": bot_id,
        "bot_version": bot_version,
        "locale_id": locale_id,
        "nlu_intent_confidence_threshold": nlu_intent_confidence_threshold,
    }
    if description is not None:
        input_["description"] = description
    if voice_settings is not None:
        input_["voice_settings"] = voice_settings
    if unified_speech_settings is not None:
        input_["unified_speech_settings"] = unified_speech_settings
    if audio_filler_settings is not None:
        input_["audio_filler_settings"] = audio_filler_settings
    if speech_recognition_settings is not None:
        input_["speech_recognition_settings"] = speech_recognition_settings
    if generative_ai_settings is not None:
        input_["generative_ai_settings"] = generative_ai_settings
    if speech_detection_sensitivity is not None:
        input_["speech_detection_sensitivity"] = speech_detection_sensitivity
    if speaker_diarization_settings is not None:
        input_["speaker_diarization_settings"] = speaker_diarization_settings

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