Amazon Chime SDK Messaging

2021/10/26 - Amazon Chime SDK Messaging - 2 new 3 updated api methods

Changes  The Amazon Chime SDK now supports push notifications through Amazon Pinpoint

PutChannelMembershipPreferences (new) Link ¶

Sets the membership preferences of an AppInstanceUser for the specified channel. The AppInstanceUser must be a member of the channel. Only the AppInstanceUser who owns the membership can set preferences. Users in the AppInstanceAdmin and channel moderator roles can't set preferences for other users. Banned users can't set membership preferences for the channel from which they are banned.

See also: AWS API Documentation

Request Syntax

client.put_channel_membership_preferences(
    ChannelArn='string',
    MemberArn='string',
    ChimeBearer='string',
    Preferences={
        'PushNotifications': {
            'AllowNotifications': 'ALL'|'NONE'|'FILTERED',
            'FilterRule': 'string'
        }
    }
)
type ChannelArn

string

param ChannelArn

[REQUIRED]

The ARN of the channel.

type MemberArn

string

param MemberArn

[REQUIRED]

The AppInstanceUserArn of the member setting the preferences.

type ChimeBearer

string

param ChimeBearer

[REQUIRED]

The AppInstanceUserARN of the user making the API call.

type Preferences

dict

param Preferences

[REQUIRED]

The channel membership preferences of an AppInstanceUser .

  • PushNotifications (dict) --

    The push notification configuration of a message.

    • AllowNotifications (string) -- [REQUIRED]

      Enum value that indicates which push notifications to send to the requested member of a channel. ALL sends all push notifications, NONE sends no push notifications, FILTERED sends only filtered push notifications.

    • FilterRule (string) --

      The simple JSON object used to send a subset of a push notification to the requsted member.

rtype

dict

returns

Response Syntax

{
    'ChannelArn': 'string',
    'Member': {
        'Arn': 'string',
        'Name': 'string'
    },
    'Preferences': {
        'PushNotifications': {
            'AllowNotifications': 'ALL'|'NONE'|'FILTERED',
            'FilterRule': 'string'
        }
    }
}

Response Structure

  • (dict) --

    • ChannelArn (string) --

      The ARN of the channel.

    • Member (dict) --

      The details of a user.

      • Arn (string) --

        The ARN in an Identity.

      • Name (string) --

        The name in an Identity.

    • Preferences (dict) --

      The ARN and metadata of the member being added.

      • PushNotifications (dict) --

        The push notification configuration of a message.

        • AllowNotifications (string) --

          Enum value that indicates which push notifications to send to the requested member of a channel. ALL sends all push notifications, NONE sends no push notifications, FILTERED sends only filtered push notifications.

        • FilterRule (string) --

          The simple JSON object used to send a subset of a push notification to the requsted member.

GetChannelMembershipPreferences (new) Link ¶

Gets the membership preferences of an AppInstanceUser for the specified channel. The AppInstanceUser must be a member of the channel. Only the AppInstanceUser who owns the membership can retrieve preferences. Users in the AppInstanceAdmin and channel moderator roles can't retrieve preferences for other users. Banned users can't retrieve membership preferences for the channel from which they are banned.

See also: AWS API Documentation

Request Syntax

client.get_channel_membership_preferences(
    ChannelArn='string',
    MemberArn='string',
    ChimeBearer='string'
)
type ChannelArn

string

param ChannelArn

[REQUIRED]

The ARN of the channel.

type MemberArn

string

param MemberArn

[REQUIRED]

The AppInstanceUserArn of the member retrieving the preferences.

type ChimeBearer

string

param ChimeBearer

[REQUIRED]

The AppInstanceUserARN of the user making the API call.

rtype

dict

returns

Response Syntax

{
    'ChannelArn': 'string',
    'Member': {
        'Arn': 'string',
        'Name': 'string'
    },
    'Preferences': {
        'PushNotifications': {
            'AllowNotifications': 'ALL'|'NONE'|'FILTERED',
            'FilterRule': 'string'
        }
    }
}

Response Structure

  • (dict) --

    • ChannelArn (string) --

      The ARN of the channel.

    • Member (dict) --

      The details of a user.

      • Arn (string) --

        The ARN in an Identity.

      • Name (string) --

        The name in an Identity.

    • Preferences (dict) --

      The channel membership preferences for an AppInstanceUser .

      • PushNotifications (dict) --

        The push notification configuration of a message.

        • AllowNotifications (string) --

          Enum value that indicates which push notifications to send to the requested member of a channel. ALL sends all push notifications, NONE sends no push notifications, FILTERED sends only filtered push notifications.

        • FilterRule (string) --

          The simple JSON object used to send a subset of a push notification to the requsted member.

GetChannelMessage (updated) Link ¶
Changes (response)
{'ChannelMessage': {'MessageAttributes': {'string': {'StringValues': ['string']}}}}

Gets the full details of a channel message.

Note

The x-amz-chime-bearer request header is mandatory. Use the AppInstanceUserArn of the user that makes the API call as the value in the header.

See also: AWS API Documentation

Request Syntax

client.get_channel_message(
    ChannelArn='string',
    MessageId='string',
    ChimeBearer='string'
)
type ChannelArn

string

param ChannelArn

[REQUIRED]

The ARN of the channel.

type MessageId

string

param MessageId

[REQUIRED]

The ID of the message.

type ChimeBearer

string

param ChimeBearer

[REQUIRED]

The AppInstanceUserArn of the user that makes the API call.

rtype

dict

returns

Response Syntax

{
    'ChannelMessage': {
        'ChannelArn': 'string',
        'MessageId': 'string',
        'Content': 'string',
        'Metadata': 'string',
        'Type': 'STANDARD'|'CONTROL',
        'CreatedTimestamp': datetime(2015, 1, 1),
        'LastEditedTimestamp': datetime(2015, 1, 1),
        'LastUpdatedTimestamp': datetime(2015, 1, 1),
        'Sender': {
            'Arn': 'string',
            'Name': 'string'
        },
        'Redacted': True|False,
        'Persistence': 'PERSISTENT'|'NON_PERSISTENT',
        'Status': {
            'Value': 'SENT'|'PENDING'|'FAILED'|'DENIED',
            'Detail': 'string'
        },
        'MessageAttributes': {
            'string': {
                'StringValues': [
                    'string',
                ]
            }
        }
    }
}

Response Structure

  • (dict) --

    • ChannelMessage (dict) --

      The details of and content in the message.

      • ChannelArn (string) --

        The ARN of the channel.

      • MessageId (string) --

        The ID of a message.

      • Content (string) --

        The message content.

      • Metadata (string) --

        The message metadata.

      • Type (string) --

        The message type.

      • CreatedTimestamp (datetime) --

        The time at which the message was created.

      • LastEditedTimestamp (datetime) --

        The time at which a message was edited.

      • LastUpdatedTimestamp (datetime) --

        The time at which a message was updated.

      • Sender (dict) --

        The message sender.

        • Arn (string) --

          The ARN in an Identity.

        • Name (string) --

          The name in an Identity.

      • Redacted (boolean) --

        Hides the content of a message.

      • Persistence (string) --

        The persistence setting for a channel message.

      • Status (dict) --

        The status of the channel message.

        • Value (string) --

          The message status value.

        • Detail (string) --

          Contains more details about the messasge status.

      • MessageAttributes (dict) --

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

        • (string) --

          • (dict) --

            A list of message attribute values.

            • StringValues (list) --

              The strings in a message attribute value.

              • (string) --

ListChannelMessages (updated) Link ¶
Changes (response)
{'ChannelMessages': {'MessageAttributes': {'string': {'StringValues': ['string']}}}}

List all the messages in a channel. Returns a paginated list of ChannelMessages . By default, sorted by creation timestamp in descending order.

Note

Redacted messages appear in the results as empty, since they are only redacted, not deleted. Deleted messages do not appear in the results. This action always returns the latest version of an edited message.

Also, the x-amz-chime-bearer request header is mandatory. Use the AppInstanceUserArn of the user that makes the API call as the value in the header.

See also: AWS API Documentation

Request Syntax

client.list_channel_messages(
    ChannelArn='string',
    SortOrder='ASCENDING'|'DESCENDING',
    NotBefore=datetime(2015, 1, 1),
    NotAfter=datetime(2015, 1, 1),
    MaxResults=123,
    NextToken='string',
    ChimeBearer='string'
)
type ChannelArn

string

param ChannelArn

[REQUIRED]

The ARN of the channel.

type SortOrder

string

param SortOrder

The order in which you want messages sorted. Default is Descending, based on time created.

type NotBefore

datetime

param NotBefore

The initial or starting time stamp for your requested messages.

type NotAfter

datetime

param NotAfter

The final or ending time stamp for your requested messages.

type MaxResults

integer

param MaxResults

The maximum number of messages that you want returned.

type NextToken

string

param NextToken

The token passed by previous API calls until all requested messages are returned.

type ChimeBearer

string

param ChimeBearer

[REQUIRED]

The AppInstanceUserArn of the user that makes the API call.

rtype

dict

returns

Response Syntax

{
    'ChannelArn': 'string',
    'NextToken': 'string',
    'ChannelMessages': [
        {
            'MessageId': 'string',
            'Content': 'string',
            'Metadata': 'string',
            'Type': 'STANDARD'|'CONTROL',
            'CreatedTimestamp': datetime(2015, 1, 1),
            'LastUpdatedTimestamp': datetime(2015, 1, 1),
            'LastEditedTimestamp': datetime(2015, 1, 1),
            'Sender': {
                'Arn': 'string',
                'Name': 'string'
            },
            'Redacted': True|False,
            'Status': {
                'Value': 'SENT'|'PENDING'|'FAILED'|'DENIED',
                'Detail': 'string'
            },
            'MessageAttributes': {
                'string': {
                    'StringValues': [
                        'string',
                    ]
                }
            }
        },
    ]
}

Response Structure

  • (dict) --

    • ChannelArn (string) --

      The ARN of the channel containing the requested messages.

    • NextToken (string) --

      The token passed by previous API calls until all requested messages are returned.

    • ChannelMessages (list) --

      The information about, and content of, each requested message.

      • (dict) --

        Summary of the messages in a Channel .

        • MessageId (string) --

          The ID of the message.

        • Content (string) --

          The content of the message.

        • Metadata (string) --

          The metadata of the message.

        • Type (string) --

          The type of message.

        • CreatedTimestamp (datetime) --

          The time at which the message summary was created.

        • LastUpdatedTimestamp (datetime) --

          The time at which a message was last updated.

        • LastEditedTimestamp (datetime) --

          The time at which a message was last edited.

        • Sender (dict) --

          The message sender.

          • Arn (string) --

            The ARN in an Identity.

          • Name (string) --

            The name in an Identity.

        • Redacted (boolean) --

          Indicates whether a message was redacted.

        • Status (dict) --

          The message status. The status value is SENT for messages sent to a channel without a channel flow. For channels associated with channel flow, the value determines the processing stage.

          • Value (string) --

            The message status value.

          • Detail (string) --

            Contains more details about the messasge status.

        • MessageAttributes (dict) --

          The message attribues listed in a the summary of a channel message.

          • (string) --

            • (dict) --

              A list of message attribute values.

              • StringValues (list) --

                The strings in a message attribute value.

                • (string) --

SendChannelMessage (updated) Link ¶
Changes (request)
{'MessageAttributes': {'string': {'StringValues': ['string']}},
 'PushNotification': {'Body': 'string',
                      'Title': 'string',
                      'Type': 'DEFAULT | VOIP'}}

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

Note

The x-amz-chime-bearer request header is mandatory. Use the AppInstanceUserArn of the user that makes the API call as the value in the header.

Also, STANDARD messages can contain 4KB of data and the 1KB of metadata. CONTROL messages can contain 30 bytes of data and no metadata.

See also: AWS API Documentation

Request Syntax

client.send_channel_message(
    ChannelArn='string',
    Content='string',
    Type='STANDARD'|'CONTROL',
    Persistence='PERSISTENT'|'NON_PERSISTENT',
    Metadata='string',
    ClientRequestToken='string',
    ChimeBearer='string',
    PushNotification={
        'Title': 'string',
        'Body': 'string',
        'Type': 'DEFAULT'|'VOIP'
    },
    MessageAttributes={
        'string': {
            'StringValues': [
                'string',
            ]
        }
    }
)
type ChannelArn

string

param ChannelArn

[REQUIRED]

The ARN of the channel.

type Content

string

param Content

[REQUIRED]

The content of the message.

type Type

string

param Type

[REQUIRED]

The type of message, STANDARD or CONTROL .

type Persistence

string

param Persistence

[REQUIRED]

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

type Metadata

string

param Metadata

The optional metadata for each message.

type ClientRequestToken

string

param ClientRequestToken

[REQUIRED]

The Idempotency token for each client request.

This field is autopopulated if not provided.

type ChimeBearer

string

param ChimeBearer

[REQUIRED]

The AppInstanceUserArn of the user that makes the API call.

type PushNotification

dict

param PushNotification

The push notification configuration of the message.

  • Title (string) -- [REQUIRED]

    The title of the push notification.

  • Body (string) -- [REQUIRED]

    The body of the push notification.

  • Type (string) -- [REQUIRED]

    Enum value that indicates the type of the push notification for a message. DEFAULT : Normal mobile push notification. VOIP : VOIP mobile push notification.

type MessageAttributes

dict

param MessageAttributes

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

  • (string) --

    • (dict) --

      A list of message attribute values.

      • StringValues (list) --

        The strings in a message attribute value.

        • (string) --

rtype

dict

returns

Response Syntax

{
    'ChannelArn': 'string',
    'MessageId': 'string',
    'Status': {
        'Value': 'SENT'|'PENDING'|'FAILED'|'DENIED',
        'Detail': 'string'
    }
}

Response Structure

  • (dict) --

    • ChannelArn (string) --

      The ARN of the channel.

    • MessageId (string) --

      The ID string assigned to each message.

    • Status (dict) --

      The status of the channel message.

      • Value (string) --

        The message status value.

      • Detail (string) --

        Contains more details about the messasge status.