Streaming messaging data in Amazon Chime SDK messaging
You can configure an AppInstance
to receive data, such as messages and
channel events, in the form of a stream. You can then react to that data in real time.
Currently, Amazon Chime SDK messaging only accepts Kinesis streams as stream destinations. You must
have these prerequisites to use Kinesis streams with this feature:
-
Kinesis streams must be in the same AWS account as the
AppInstance
. -
A stream must be in the same region as the
AppInstance
. -
Stream names have a prefix that starts with
chime-messaging-
. -
You must configure at least two shards. Each shard can receive data up to 1MB per second, so scale your stream accordingly.
-
You must enable server-side encryption (SSE).
To configure a Kinesis stream
-
Create one or more Kinesis streams using the prerequisites in the previous section, then get the ARN. Ensure the caller has Kinesis permissions in addition to Amazon Chime permissions.
The following examples show how to use the AWS CLI to create a Kinesis stream with two shards, and how to enable SSE.
aws kinesis create-stream --stream-name
chime-messaging-unique-name
--shard-count2
aws kinesis start-stream-encryption --stream-name
chime-messaging-unique-name
--encryption-type KMS --key-id "alias
/aws/kinesis" -
Configure streaming by calling the PutMessagingStreamingConfigurations API.
You can configure one or both of two data types, and you can choose the same stream or separate streams for them.
The following examples show how to use the AWS CLI to configure an
appinstance
to stream theChannelMessage
andChannel
data types.aws chime-sdk-messaging put-messaging-streaming-configurations --app-instance-arn
app_instance_arn
\ --streaming-configurations DataType=ChannelMessage,ResourceArn=kinesis_data_stream_arn
aws chime-sdk-messaging put-messaging-streaming-configurations --app-instance-arn
app_instance_arn
\ --streaming-configurations DataType=Channel,ResourceArn=kinesis_data_stream_arn
The data types have the following scopes:
DataType
Event types generated CREATE_CHANNEL_MESSAGE
REDACT_CHANNEL_MESSAGE
UPDATE_CHANNEL_MESSAGE
DELETE_CHANNEL_MESSAGE
CREATE_CHANNEL
CREATE_SUB_CHANNEL
UPDATE_CHANNEL
DELETE_CHANNEL
UPDATE_CHANNEL_EXPIRATION_SETTINGS
DELETE_SUB_CHANNEL
CREATE_CHANNEL_MEMBERSHIP
DELETE_CHANNEL_MEMBERSHIP
CREATE_CHANNEL_BAN
DELETE_CHANNEL_BAN
CREATE_CHANNEL_MODERATOR
DELETE_CHANNEL_MODERATOR
-
Start reading the data from your configured Kinesis stream.
Note
Any events sent before you configure streaming are not sent to your Kinesis stream.
Data format
Kinesis outputs records in JSON format with the following fields:
EventType
and Payload
. The payload format depends on
the EventType
. The following table lists the event types and their
corresponding payload formats.
EventType | Payload format |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|