Skip to content

send_message

send_message(
    content_type: ChatContentType,
    content: ChatContent,
    connection_token: ParticipantToken,
    *,
    config_overrides: Optional[ConnectParticipantClientConfig] = None,
    client_token: Optional[ClientToken] = None,
) -> SendMessageResponse

Sends a message.

For security recommendations, see Connect Customer Chat security best practices.

ConnectionToken is used for invoking this API instead of ParticipantToken.

The Amazon Connect Participant Service APIs do not use Signature Version 4 authentication.

Parameters:

  • content_type (ChatContentType) –

    The type of the content. Possible types are text/plain, text/markdown, application/json, and application/vnd.amazonaws.connect.message.interactive.response.

    Supported types on the contact are configured through SupportedMessagingContentTypes on StartChatContact and StartOutboundChatContact.

    For Apple Messages for Business, SMS, and WhatsApp Business Messaging contacts, only text/plain is supported.

  • content (ChatContent) –

    The content of the message.

    • For text/plain and text/markdown, the Length Constraints are Minimum of 1, Maximum of 1024.

    • For application/json, the Length Constraints are Minimum of 1, Maximum of 12000.

    • For application/vnd.amazonaws.connect.message.interactive.response, the Length Constraints are Minimum of 1, Maximum of 12288.

  • client_token (Optional[ClientToken], default: None ) –

    A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. If not provided, the Amazon Web Services SDK populates this field. For more information about idempotency, see Making retries safe with idempotent APIs.

  • connection_token (ParticipantToken) –

    The authentication token associated with the connection.

Raises:

Source code in docs_src/capo_connectparticipant/_services/connect_participant.py
def send_message(
    self,
    content_type: "capo_connectparticipant.types.chat_content_type.ChatContentType",
    content: "capo_connectparticipant.types.chat_content.ChatContent",
    connection_token: "capo_connectparticipant.types.participant_token.ParticipantToken",
    *,
    config_overrides: Optional[ConnectParticipantClientConfig] = None,
    client_token: Optional[
        "capo_connectparticipant.types.client_token.ClientToken"
    ] = None,
) -> "capo_connectparticipant.types.send_message_response.SendMessageResponse":
    """<p>Sends a message.</p> <p>For security recommendations, see <a href="https://docs.aws.amazon.com/connect/latest/adminguide/security-best-practices.html#bp-security-chat">Connect Customer Chat security best practices</a>. </p> <note> <p> <code>ConnectionToken</code> is used for invoking this API instead of <code>ParticipantToken</code>.</p> </note> <p>The Amazon Connect Participant Service APIs do not use <a href="https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html">Signature Version 4 authentication</a>.</p>

    Args:
        content_type: <p>The type of the content. Possible types are <code>text/plain</code>, <code>text/markdown</code>, <code>application/json</code>, and <code>application/vnd.amazonaws.connect.message.interactive.response</code>. </p> <p>Supported types on the contact are configured through <code>SupportedMessagingContentTypes</code> on <a href="https://docs.aws.amazon.com/connect/latest/APIReference/API_StartChatContact.html">StartChatContact</a> and <a href="https://docs.aws.amazon.com/connect/latest/APIReference/API_StartOutboundChatContact.html">StartOutboundChatContact</a>.</p> <p> For Apple Messages for Business, SMS, and WhatsApp Business Messaging contacts, only <code>text/plain</code> is supported.</p>
        content: <p>The content of the message. </p> <ul> <li> <p>For <code>text/plain</code> and <code>text/markdown</code>, the Length Constraints are Minimum of 1, Maximum of 1024. </p> </li> <li> <p>For <code>application/json</code>, the Length Constraints are Minimum of 1, Maximum of 12000. </p> </li> <li> <p>For <code>application/vnd.amazonaws.connect.message.interactive.response</code>, the Length Constraints are Minimum of 1, Maximum of 12288.</p> </li> </ul>
        client_token: <p>A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. If not provided, the Amazon Web Services SDK populates this field. For more information about idempotency, see <a href="https://aws.amazon.com/builders-library/making-retries-safe-with-idempotent-APIs/">Making retries safe with idempotent APIs</a>.</p>
        connection_token: <p>The authentication token associated with the connection.</p>

    Raises:
        capo_connectparticipant.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient access to perform this action.</p>
        capo_connectparticipant.errors.internal_server_exception.InternalServerException: <p>This exception occurs when there is an internal failure in the Amazon Connect service.</p>
        capo_connectparticipant.errors.throttling_exception.ThrottlingException: <p>The request was denied due to request throttling.</p>
        capo_connectparticipant.errors.validation_exception.ValidationException: <p>The input fails to satisfy the constraints specified by Amazon Connect.</p>
        capo_connectparticipant.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_connectparticipant.types.send_message_request.SendMessageRequest]",
    ) -> OperationResponse[
        "capo_connectparticipant.types.send_message_response.SendMessageResponse"
    ]:
        import capo_connectparticipant._operations.amazon_connect_participant_service_lambda.send_message

        output, http_response = (
            capo_connectparticipant._operations.amazon_connect_participant_service_lambda.send_message.send_message(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("SendMessage")
    )
    input_: capo_connectparticipant.types.send_message_request.SendMessageRequest = {
        "content_type": content_type,
        "content": content,
        "connection_token": connection_token,
    }
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token

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