Skip to content

send_channel_message

send_channel_message(
    channel_arn: ChimeArn,
    content: NonEmptyContent,
    type: ChannelMessageType,
    persistence: ChannelMessagePersistenceType,
    client_request_token: ClientRequestToken,
    chime_bearer: ChimeArn,
    *,
    config_overrides: Optional[ChimeSDKMessagingClientConfig] = None,
    metadata: Optional[Metadata] = None,
    push_notification: Optional[PushNotificationConfiguration] = None,
    message_attributes: Optional[MessageAttributeMap] = None,
    sub_channel_id: Optional[SubChannelId] = None,
    content_type: Optional[ContentType] = None,
    target: Optional[TargetList] = None,
) -> SendChannelMessageResponse

Sends a message to a particular channel that the member is a part of.

The x-amz-chime-bearer request header is mandatory. Use the ARN of the AppInstanceUser or AppInstanceBot that makes the API call as the value in the header.

Also, STANDARD messages can be up to 4KB in size and contain metadata. Metadata is arbitrary, and you can use it in a variety of ways, such as containing a link to an attachment.

CONTROL messages are limited to 30 bytes and do not contain metadata.

Parameters:

  • channel_arn (ChimeArn) –

    The ARN of the channel.

  • content (NonEmptyContent) –

    The content of the channel message.

  • type (ChannelMessageType) –

    The type of message, STANDARD or CONTROL.

    STANDARD messages can be up to 4KB in size and contain metadata. Metadata is arbitrary, and you can use it in a variety of ways, such as containing a link to an attachment.

    CONTROL messages are limited to 30 bytes and do not contain metadata.

  • persistence (ChannelMessagePersistenceType) –

    Boolean that controls whether the message is persisted on the back end. Required.

  • metadata (Optional[Metadata], default: None ) –

    The optional metadata for each message.

  • client_request_token (ClientRequestToken) –

    The Idempotency token for each client request.

  • chime_bearer (ChimeArn) –

    The ARN of the AppInstanceUser or AppInstanceBot that makes the API call.

  • push_notification (Optional[PushNotificationConfiguration], default: None ) –

    The push notification configuration of the message.

  • message_attributes (Optional[MessageAttributeMap], default: None ) –

    The attributes for the message, used for message filtering along with a FilterRule defined in the PushNotificationPreferences.

  • sub_channel_id (Optional[SubChannelId], default: None ) –

    The ID of the SubChannel in the request.

  • content_type (Optional[ContentType], default: None ) –

    The content type of the channel message.

  • target (Optional[TargetList], default: None ) –

    The target of a message. Must be a member of the channel, such as another user, a bot, or the sender. Only the target and the sender can view targeted messages. Only users who can see targeted messages can take actions on them. However, administrators can delete targeted messages that they can’t see.

Raises:

Source code in docs_src/capo_chime_sdk_messaging/_services/chime_sdk_messaging.py
def send_channel_message(
    self,
    channel_arn: "capo_chime_sdk_messaging.types.chime_arn.ChimeArn",
    content: "capo_chime_sdk_messaging.types.non_empty_content.NonEmptyContent",
    type: "capo_chime_sdk_messaging.types.channel_message_type.ChannelMessageType",
    persistence: "capo_chime_sdk_messaging.types.channel_message_persistence_type.ChannelMessagePersistenceType",
    client_request_token: "capo_chime_sdk_messaging.types.client_request_token.ClientRequestToken",
    chime_bearer: "capo_chime_sdk_messaging.types.chime_arn.ChimeArn",
    *,
    config_overrides: Optional[ChimeSDKMessagingClientConfig] = None,
    metadata: Optional["capo_chime_sdk_messaging.types.metadata.Metadata"] = None,
    push_notification: Optional[
        "capo_chime_sdk_messaging.types.push_notification_configuration.PushNotificationConfiguration"
    ] = None,
    message_attributes: Optional[
        "capo_chime_sdk_messaging.types.message_attribute_map.MessageAttributeMap"
    ] = None,
    sub_channel_id: Optional[
        "capo_chime_sdk_messaging.types.sub_channel_id.SubChannelId"
    ] = None,
    content_type: Optional[
        "capo_chime_sdk_messaging.types.content_type.ContentType"
    ] = None,
    target: Optional[
        "capo_chime_sdk_messaging.types.target_list.TargetList"
    ] = None,
) -> "capo_chime_sdk_messaging.types.send_channel_message_response.SendChannelMessageResponse":
    """<p>Sends a message to a particular channel that the member is a part of.</p> <note> <p>The <code>x-amz-chime-bearer</code> request header is mandatory. Use the ARN of the <code>AppInstanceUser</code> or <code>AppInstanceBot</code> that makes the API call as the value in the header.</p> <p>Also, <code>STANDARD</code> messages can be up to 4KB in size and contain metadata. Metadata is arbitrary, and you can use it in a variety of ways, such as containing a link to an attachment.</p> <p> <code>CONTROL</code> messages are limited to 30 bytes and do not contain metadata.</p> </note>

    Args:
        channel_arn: <p>The ARN of the channel.</p>
        content: <p>The content of the channel message.</p>
        type: <p>The type of message, <code>STANDARD</code> or <code>CONTROL</code>.</p> <p> <code>STANDARD</code> messages can be up to 4KB in size and contain metadata. Metadata is arbitrary, and you can use it in a variety of ways, such as containing a link to an attachment.</p> <p> <code>CONTROL</code> messages are limited to 30 bytes and do not contain metadata.</p>
        persistence: <p>Boolean that controls whether the message is persisted on the back end. Required.</p>
        metadata: <p>The optional metadata for each message.</p>
        client_request_token: <p>The <code>Idempotency</code> token for each client request.</p>
        chime_bearer: <p>The ARN of the <code>AppInstanceUser</code> or <code>AppInstanceBot</code> that makes the API call.</p>
        push_notification: <p>The push notification configuration of the message.</p>
        message_attributes: <p>The attributes for the message, used for message filtering along with a <code>FilterRule</code> defined in the <code>PushNotificationPreferences</code>.</p>
        sub_channel_id: <p>The ID of the SubChannel in the request.</p>
        content_type: <p>The content type of the channel message.</p>
        target: <p>The target of a message. Must be a member of the channel, such as another user, a bot, or the sender. Only the target and the sender can view targeted messages. Only users who can see targeted messages can take actions on them. However, administrators can delete targeted messages that they can’t see. </p>

    Raises:
        capo_chime_sdk_messaging.errors.bad_request_exception.BadRequestException: <p>The input parameters don't match the service's restrictions.</p>
        capo_chime_sdk_messaging.errors.conflict_exception.ConflictException: <p>The request could not be processed because of conflict in the current state of the resource.</p>
        capo_chime_sdk_messaging.errors.forbidden_exception.ForbiddenException: <p>The client is permanently forbidden from making the request.</p>
        capo_chime_sdk_messaging.errors.service_failure_exception.ServiceFailureException: <p>The service encountered an unexpected error.</p>
        capo_chime_sdk_messaging.errors.service_unavailable_exception.ServiceUnavailableException: <p>The service is currently unavailable.</p>
        capo_chime_sdk_messaging.errors.throttled_client_exception.ThrottledClientException: <p>The client exceeded its request rate limit.</p>
        capo_chime_sdk_messaging.errors.unauthorized_client_exception.UnauthorizedClientException: <p>The client is not currently authorized to make the request.</p>
        capo_chime_sdk_messaging.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_chime_sdk_messaging.types.send_channel_message_request.SendChannelMessageRequest]",
    ) -> OperationResponse[
        "capo_chime_sdk_messaging.types.send_channel_message_response.SendChannelMessageResponse"
    ]:
        import capo_chime_sdk_messaging._operations.chime_messaging_service.send_channel_message

        output, http_response = (
            capo_chime_sdk_messaging._operations.chime_messaging_service.send_channel_message.send_channel_message(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_chime_sdk_messaging.types.send_channel_message_request.SendChannelMessageRequest",
    ) -> dict[str, Any]:
        import capo_chime_sdk_messaging.types.send_channel_message_request

        return capo_chime_sdk_messaging.types.send_channel_message_request.redact_sensitive(
            input_
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("SendChannelMessage", redact_input=_redact_input),
    )
    input_: capo_chime_sdk_messaging.types.send_channel_message_request.SendChannelMessageRequest = {
        "channel_arn": channel_arn,
        "content": content,
        "type": type,
        "persistence": persistence,
        "client_request_token": client_request_token,
        "chime_bearer": chime_bearer,
    }
    if metadata is not None:
        input_["metadata"] = metadata
    if push_notification is not None:
        input_["push_notification"] = push_notification
    if message_attributes is not None:
        input_["message_attributes"] = message_attributes
    if sub_channel_id is not None:
        input_["sub_channel_id"] = sub_channel_id
    if content_type is not None:
        input_["content_type"] = content_type
    if target is not None:
        input_["target"] = target

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