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-namechime-messaging-unique-name--shard-count2aws kinesis start-stream-encryption --stream-namechime-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
appinstanceto stream theChannelMessageandChanneldata types.aws chime-sdk-messaging put-messaging-streaming-configurations --app-instance-arnapp_instance_arn\ --streaming-configurations DataType=ChannelMessage,ResourceArn=kinesis_data_stream_arnaws chime-sdk-messaging put-messaging-streaming-configurations --app-instance-arnapp_instance_arn\ --streaming-configurations DataType=Channel,ResourceArn=kinesis_data_stream_arnThe data types have the following scopes:
DataTypeEvent types generated CREATE_CHANNEL_MESSAGEREDACT_CHANNEL_MESSAGEUPDATE_CHANNEL_MESSAGEDELETE_CHANNEL_MESSAGECREATE_CHANNELCREATE_SUB_CHANNELUPDATE_CHANNELDELETE_CHANNELUPDATE_CHANNEL_EXPIRATION_SETTINGSDELETE_SUB_CHANNELCREATE_CHANNEL_MEMBERSHIPDELETE_CHANNEL_MEMBERSHIPCREATE_CHANNEL_BANDELETE_CHANNEL_BANCREATE_CHANNEL_MODERATORDELETE_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 |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|