Skip to content

send_whats_app_message

send_whats_app_message(
    origination_phone_number_id: WhatsAppPhoneNumberId,
    message: WhatsAppMessageBlob,
    meta_api_version: str,
    *,
    config_overrides: Optional[SocialMessagingClientConfig] = None,
) -> SendWhatsAppMessageOutput

Send a WhatsApp message. For examples of sending a message using the Amazon Web Services CLI, see Sending messages in the Amazon Web Services End User Messaging Social User Guide .

Parameters:

  • origination_phone_number_id (WhatsAppPhoneNumberId) –

    The ID of the phone number used to send the WhatsApp message. If you are sending a media file only the originationPhoneNumberId used to upload the file can be used. Phone number identifiers are formatted as phone-number-id-01234567890123456789012345678901. Use GetLinkedWhatsAppBusinessAccount to find a phone number's id.

  • message (WhatsAppMessageBlob) –

    The message to send through WhatsApp. The length is in KB. The message field passes through a WhatsApp Message object, see Messages in the WhatsApp Business Platform Cloud API Reference.

  • meta_api_version (str) –

    The API version for the request formatted as v{VersionNumber}. For a list of supported API versions and Amazon Web Services Regions, see Amazon Web Services End User Messaging Social API Service Endpoints in the Amazon Web Services General Reference.

Raises:

Source code in docs_src/capo_socialmessaging/_services/social_messaging.py
def send_whats_app_message(
    self,
    origination_phone_number_id: "capo_socialmessaging.types.whats_app_phone_number_id.WhatsAppPhoneNumberId",
    message: "capo_socialmessaging.types.whats_app_message_blob.WhatsAppMessageBlob",
    meta_api_version: str,
    *,
    config_overrides: Optional[SocialMessagingClientConfig] = None,
) -> "capo_socialmessaging.types.send_whats_app_message_output.SendWhatsAppMessageOutput":
    """<p>Send a WhatsApp message. For examples of sending a message using the Amazon Web Services CLI, see <a href="https://docs.aws.amazon.com/social-messaging/latest/userguide/send-message.html">Sending messages</a> in the <i> <i>Amazon Web Services End User Messaging Social User Guide</i> </i>.</p>

    Args:
        origination_phone_number_id: <p>The ID of the phone number used to send the WhatsApp message. If you are sending a media file only the <code>originationPhoneNumberId</code> used to upload the file can be used. Phone number identifiers are formatted as <code>phone-number-id-01234567890123456789012345678901</code>. Use <a href="https://docs.aws.amazon.com/social-messaging/latest/APIReference/API_GetLinkedWhatsAppBusinessAccount.html">GetLinkedWhatsAppBusinessAccount</a> to find a phone number's id.</p>
        message: <p>The message to send through WhatsApp. The length is in KB. The message field passes through a WhatsApp Message object, see <a href="https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages">Messages</a> in the <i>WhatsApp Business Platform Cloud API Reference</i>.</p>
        meta_api_version: <p>The API version for the request formatted as <code>v{VersionNumber}</code>. For a list of supported API versions and Amazon Web Services Regions, see <a href="https://docs.aws.amazon.com/general/latest/gr/end-user-messaging.html"> <i>Amazon Web Services End User Messaging Social API</i> Service Endpoints</a> in the <i>Amazon Web Services General Reference</i>.</p>

    Raises:
        capo_socialmessaging.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient access to perform this action.</p>
        capo_socialmessaging.errors.validation_exception.ValidationException: <p>The request contains an invalid parameter value. </p>
        capo_socialmessaging.errors.dependency_exception.DependencyException: <p>Thrown when performing an action because a dependency would be broken.</p>
        capo_socialmessaging.errors.internal_service_exception.InternalServiceException: <p>The request processing has failed because of an unknown error, exception, or failure.</p>
        capo_socialmessaging.errors.invalid_parameters_exception.InvalidParametersException: <p>One or more parameters provided to the action are not valid.</p>
        capo_socialmessaging.errors.resource_not_found_exception.ResourceNotFoundException: <p>The resource was not found.</p>
        capo_socialmessaging.errors.throttled_request_exception.ThrottledRequestException: <p>The request was denied due to request throttling.</p>
        capo_socialmessaging.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_socialmessaging.types.send_whats_app_message_input.SendWhatsAppMessageInput]",
    ) -> OperationResponse[
        "capo_socialmessaging.types.send_whats_app_message_output.SendWhatsAppMessageOutput"
    ]:
        import capo_socialmessaging._operations.social_messaging.send_whats_app_message

        output, http_response = (
            capo_socialmessaging._operations.social_messaging.send_whats_app_message.send_whats_app_message(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_socialmessaging.types.send_whats_app_message_input.SendWhatsAppMessageInput",
    ) -> dict[str, Any]:
        import capo_socialmessaging.types.send_whats_app_message_input

        return capo_socialmessaging.types.send_whats_app_message_input.redact_sensitive(
            input_
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("SendWhatsAppMessage", redact_input=_redact_input),
    )
    input_: capo_socialmessaging.types.send_whats_app_message_input.SendWhatsAppMessageInput = {
        "origination_phone_number_id": origination_phone_number_id,
        "message": message,
        "meta_api_version": meta_api_version,
    }

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