Skip to content

send_notify_voice_message

send_notify_voice_message(
    notify_configuration_id: NotifyConfigurationIdOrArn,
    destination_phone_number: PhoneNumber,
    template_variables: TemplateVariableSubstitutionMap,
    *,
    config_overrides: Optional[PinpointSMSVoiceV2ClientConfig] = None,
    template_id: Optional[NotifyTemplateId] = None,
    voice_id: Optional[VoiceId] = None,
    time_to_live: Optional[TimeToLive] = None,
    context: Optional[ContextMap] = None,
    configuration_set_name: Optional[ConfigurationSetNameOrArn] = None,
    dry_run: Optional[bool] = None,
    message_feedback_enabled: Optional[bool] = None,
) -> SendNotifyVoiceMessageResult

Sends a templated voice message through a notify configuration to a recipient's phone number.

Parameters:

  • notify_configuration_id (NotifyConfigurationIdOrArn) –

    The unique identifier of the notify configuration to use for sending the message. This can be either the NotifyConfigurationId or NotifyConfigurationArn.

  • destination_phone_number (PhoneNumber) –

    The destination phone number in E.164 format.

  • template_id (Optional[NotifyTemplateId], default: None ) –

    The unique identifier of the template to use for the message.

  • template_variables (TemplateVariableSubstitutionMap) –

    A map of template variable names and their values. All variable values are passed as strings regardless of the declared variable type. For example, pass INTEGER values as "42" and BOOLEAN values as "true" or "false".

  • voice_id (Optional[VoiceId], default: None ) –

    The voice ID to use for the voice message.

  • time_to_live (Optional[TimeToLive], default: None ) –

    How long the voice message is valid for, in seconds. By default this is 72 hours.

  • context (Optional[ContextMap], default: None ) –

    You can specify custom data in this field. If you do, that data is logged to the event destination.

  • configuration_set_name (Optional[ConfigurationSetNameOrArn], default: None ) –

    The name of the configuration set to use. This can be either the ConfigurationSetName or ConfigurationSetArn.

  • dry_run (Optional[bool], default: None ) –

    When set to true, the message is checked and validated, but isn't sent to the end recipient.

  • message_feedback_enabled (Optional[bool], default: None ) –

    Set to true to enable message feedback for the message. When a user receives the message you need to update the message status using PutMessageFeedback.

Raises:

  • AccessDeniedException –

    The request was denied because you don't have sufficient permissions to access the resource.

  • ConflictException –

    Your request has conflicting operations. This can occur if you're trying to perform more than one operation on the same resource at the same time or it could be that the requested action isn't valid for the current state or configuration of the resource.

  • InternalServerException –

    The API encountered an unexpected error and couldn't complete the request. You might be able to successfully issue the request again in the future.

  • ResourceNotFoundException –

    A requested resource couldn't be found.

  • ServiceQuotaExceededException –

    The request would cause a service quota to be exceeded.

  • ThrottlingException –

    An error that occurred because too many requests were sent during a certain amount of time.

  • ValidationException –

    A validation exception for a field.

  • UnknownServiceError –

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

Examples:

SendNotifyVoiceMessage Send an OTP verification code via voice call using a notify configuration.

>>> client.send_notify_voice_message(notify_configuration_id='nc-1234567890abcdef0', destination_phone_number='+12065550100', template_variables={'code': '123456', 'expiry': '10'}, voice_id='JOANNA')
Source code in docs_src/capo_pinpoint_sms_voice_v2/_services/pinpoint_sms_voice_v2.py
def send_notify_voice_message(
    self,
    notify_configuration_id: "capo_pinpoint_sms_voice_v2.types.notify_configuration_id_or_arn.NotifyConfigurationIdOrArn",
    destination_phone_number: "capo_pinpoint_sms_voice_v2.types.phone_number.PhoneNumber",
    template_variables: "capo_pinpoint_sms_voice_v2.types.template_variable_substitution_map.TemplateVariableSubstitutionMap",
    *,
    config_overrides: Optional[PinpointSMSVoiceV2ClientConfig] = None,
    template_id: Optional[
        "capo_pinpoint_sms_voice_v2.types.notify_template_id.NotifyTemplateId"
    ] = None,
    voice_id: Optional["capo_pinpoint_sms_voice_v2.types.voice_id.VoiceId"] = None,
    time_to_live: Optional[
        "capo_pinpoint_sms_voice_v2.types.time_to_live.TimeToLive"
    ] = None,
    context: Optional[
        "capo_pinpoint_sms_voice_v2.types.context_map.ContextMap"
    ] = None,
    configuration_set_name: Optional[
        "capo_pinpoint_sms_voice_v2.types.configuration_set_name_or_arn.ConfigurationSetNameOrArn"
    ] = None,
    dry_run: Optional[bool] = None,
    message_feedback_enabled: Optional[bool] = None,
) -> "capo_pinpoint_sms_voice_v2.types.send_notify_voice_message_result.SendNotifyVoiceMessageResult":
    """<p>Sends a templated voice message through a notify configuration to a recipient's phone number.</p>

    Args:
        notify_configuration_id: <p>The unique identifier of the notify configuration to use for sending the message. This can be either the NotifyConfigurationId or NotifyConfigurationArn.</p>
        destination_phone_number: <p>The destination phone number in E.164 format.</p>
        template_id: <p>The unique identifier of the template to use for the message.</p>
        template_variables: <p>A map of template variable names and their values. All variable values are passed as strings regardless of the declared variable type. For example, pass <code>INTEGER</code> values as <code>"42"</code> and <code>BOOLEAN</code> values as <code>"true"</code> or <code>"false"</code>.</p>
        voice_id: <p>The voice ID to use for the voice message.</p>
        time_to_live: <p>How long the voice message is valid for, in seconds. By default this is 72 hours.</p>
        context: <p>You can specify custom data in this field. If you do, that data is logged to the event destination.</p>
        configuration_set_name: <p>The name of the configuration set to use. This can be either the ConfigurationSetName or ConfigurationSetArn.</p>
        dry_run: <p>When set to true, the message is checked and validated, but isn't sent to the end recipient.</p>
        message_feedback_enabled: <p>Set to true to enable message feedback for the message. When a user receives the message you need to update the message status using <a>PutMessageFeedback</a>.</p>

    Raises:
        capo_pinpoint_sms_voice_v2.errors.access_denied_exception.AccessDeniedException: <p>The request was denied because you don't have sufficient permissions to access the resource.</p>
        capo_pinpoint_sms_voice_v2.errors.conflict_exception.ConflictException: <p>Your request has conflicting operations. This can occur if you're trying to perform more than one operation on the same resource at the same time or it could be that the requested action isn't valid for the current state or configuration of the resource.</p>
        capo_pinpoint_sms_voice_v2.errors.internal_server_exception.InternalServerException: <p>The API encountered an unexpected error and couldn't complete the request. You might be able to successfully issue the request again in the future.</p>
        capo_pinpoint_sms_voice_v2.errors.resource_not_found_exception.ResourceNotFoundException: <p>A requested resource couldn't be found.</p>
        capo_pinpoint_sms_voice_v2.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The request would cause a service quota to be exceeded.</p>
        capo_pinpoint_sms_voice_v2.errors.throttling_exception.ThrottlingException: <p>An error that occurred because too many requests were sent during a certain amount of time.</p>
        capo_pinpoint_sms_voice_v2.errors.validation_exception.ValidationException: <p>A validation exception for a field.</p>
        capo_pinpoint_sms_voice_v2.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        SendNotifyVoiceMessage
        Send an OTP verification code via voice call using a notify configuration.

        >>> client.send_notify_voice_message(notify_configuration_id='nc-1234567890abcdef0', destination_phone_number='+12065550100', template_variables={'code': '123456', 'expiry': '10'}, voice_id='JOANNA')
    """

    def _handler(
        req: "OperationRequest[capo_pinpoint_sms_voice_v2.types.send_notify_voice_message_request.SendNotifyVoiceMessageRequest]",
    ) -> OperationResponse[
        "capo_pinpoint_sms_voice_v2.types.send_notify_voice_message_result.SendNotifyVoiceMessageResult"
    ]:
        import capo_pinpoint_sms_voice_v2._operations.pinpoint_sms_voice_v2.send_notify_voice_message

        output, http_response = (
            capo_pinpoint_sms_voice_v2._operations.pinpoint_sms_voice_v2.send_notify_voice_message.send_notify_voice_message(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("SendNotifyVoiceMessage")
    )
    input_: capo_pinpoint_sms_voice_v2.types.send_notify_voice_message_request.SendNotifyVoiceMessageRequest = {
        "notify_configuration_id": notify_configuration_id,
        "destination_phone_number": destination_phone_number,
        "template_variables": template_variables,
    }
    if template_id is not None:
        input_["template_id"] = template_id
    if voice_id is not None:
        input_["voice_id"] = voice_id
    if time_to_live is not None:
        input_["time_to_live"] = time_to_live
    if context is not None:
        input_["context"] = context
    if configuration_set_name is not None:
        input_["configuration_set_name"] = configuration_set_name
    if dry_run is not None:
        input_["dry_run"] = dry_run
    if message_feedback_enabled is not None:
        input_["message_feedback_enabled"] = message_feedback_enabled

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