

# Automating the Amazon Chime SDK with EventBridge
<a name="automating-chime-with-cloudwatch-events"></a>

Amazon EventBridge lets you automate your AWS services and respond automatically to system events, such as application availability issues or resource changes. For more information about the meeting events, see [Meeting events](https://docs.aws.amazon.com/chime/latest/dg/using-events.html) in the *Amazon Chime SDK Developer Guide*.

When the Amazon Chime SDK generates events, it sends them to EventBridge for *best effort delivery*, meaning the Amazon Chime SDK tries to send all events to EventBridge, but in rare cases an event might not be delivered. For more information, refer to [Events from AWS services](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-service-event.html) in the *Amazon EventBridge User Guide*.

**Note**  
If you need to encrypt data, you must use Amazon S3-Managed Keys. We don't support server-side encryption using Customer Master Keys stored in the AWS Key Management Service. 

## Automating Amazon Chime SDK Voice Connectors with EventBridge
<a name="events-cvc"></a>

The actions that can be automatically triggered for Amazon Chime SDK Voice Connectors include the following:
+ Invoking an AWS Lambda function
+ Launching an Amazon Elastic Container Service task
+ Relaying the event to Amazon Kinesis Video Streams
+ Activating an AWS Step Functions state machine
+ Notifying an Amazon SNS topic or an Amazon SQS queue

Some examples of using EventBridge with Amazon Chime SDK Voice Connectors include:
+ Activating a Lambda function to download audio for a call after the call is ended.
+ Launching an Amazon ECS task to enable real-time transcription after a call is started.

For more information, see the [Amazon EventBridge User Guide](https://docs.aws.amazon.com/eventbridge/latest/userguide/).

## Amazon Chime SDK Voice Connector streaming events
<a name="stream-events-cvc"></a>

Amazon Chime SDK Voice Connectors support sending events to EventBridge when the events discussed in this section occur.

### Amazon Chime SDK Voice Connector streaming starts
<a name="stream-start-cvc"></a>

Amazon Chime SDK Voice Connectors send this event when media streaming to Kinesis Video Streams starts.

**Example Event data**  
The following is example data for this event.  

```
{
    "version": "0",
    "id": "12345678-1234-1234-1234-111122223333",
    "detail-type": "Chime VoiceConnector Streaming Status",
    "source": "aws.chime",
    "account": "{{111122223333}}",
    "time": "{{yyyy-mm-ddThh:mm:ssZ}}",
    "region": "us-east-1",
    "resources": [],
    "detail": {
        "callId": "{{1112-2222-4333}}",
        "direction": "Outbound",
        "fromNumber": "+{{12065550100}}",
        "inviteHeaders": {
            "from": "\"{{John}}\" <sip:{{+12065550100}}@10.24.34.0>;{{tag=abcdefg}}",
            "to": "<sip:{{+13605550199@abcdef1ghij2klmno3pqr4M}}.voiceconnector.chime.aws:5060>",
            "call-id": "{{1112-2222-4333}}",
            "cseq": "101 INVITE",
            "contact": "<sip:user@10.24.34.0:6090>;",
            "content-type": "application/sdp",
            "content-length": "{{246}}"
        },
        "isCaller": false,
        "mediaType": "audio/L16",
        "sdp": {
            "mediaIndex": 0,
            "mediaLabel": "1"
        },
        "siprecMetadata": "<&xml version=\"1.0\" encoding=\"UTF-8\"&>;\r\n<recording xmlns='urn:ietf:params:xml:ns:recording:1'>",
        "startFragmentNumber": "{{1234567899444}}",
        "startTime": "{{yyyy-mm-ddThh:mm:ssZ}}",
        "streamArn": "arn:aws:kinesisvideo:us-east-1:{{123456M}}:stream/ChimeVoiceConnector-{{abcdef1ghij2klmno3pqr4-111aaa-22bb-33cc-44dd-111222}}/111122223333",
        "toNumber": "+{{13605550199}}",
        "transactionId": "{{12345678-1234-1234}}",
        "voiceConnectorId": "{{abcdef1ghij2klmno3pqr4}}",
        "streamingStatus": "STARTED",
        "version": "0"
    }
}
```

### Amazon Chime SDK Voice Connector streaming ends
<a name="stream-end-cvc"></a>

Amazon Chime SDK Voice Connectors send this event when media streaming to Kinesis Video Streams ends.

**Example Event data**  
The following is example data for this event.  

```
{
    "version": "0",
    "id": "{{12345678-1234-1234-1234-111122223333}}",
    "detail-type": "Chime VoiceConnector Streaming Status",
    "source": "aws.chime",
    "account": "{{111122223333}}",
    "time": "{{yyyy-mm-ddThh:mm:ssZ}}",
    "region": "us-east-1",
    "resources": [],
    "detail": {
        "streamingStatus": "ENDED",
        "voiceConnectorId": "{{abcdef1ghij2klmno3pqr4}}",
        "transactionId": "{{12345678-1234-1234}}",
        "callId": "{{1112-2222-4333}}",
        "direction": "Inbound",
        "fromNumber": "+{{12065550100}}",
        "inviteHeaders": {
            "from": "\"{{John}}\" <sip:+{{12065550100}}@10.24.34.0>;tag={{abcdefg}}",
            "to": "<sip:+{{13605550199}}@{{abcdef1ghij2klmno3pqr4}}.voiceconnector.chime.aws:5060>",
            "call-id": "{{1112-2222-4333}}",
            "cseq": "101 INVITE",
            "contact": "<sip:user@10.24.34.0:6090>",
            "content-type": "application/sdp",
            "content-length": "{{246}}"
        },
        "isCaller": false,
        "mediaType": "audio/L16",
        "sdp": {
            "mediaIndex": 0,
            "mediaLabel": "1"
        },
        "siprecMetadata": "<&xml version=\"1.0\" encoding=\"UTF-8\"&>\r\n<recording xmlns='urn:ietf:params:xml:ns:recording:1'>",
        "startFragmentNumber": "{{1234567899444}}",
        "startTime": "{{yyyy-mm-ddThh:mm:ssZ}}",
        "endTime": "{{yyyy-mm-ddThh:mm:ssZ}}",
        "streamArn": "arn:aws:kinesisvideo:us-east-1:{{123456}}:stream/ChimeVoiceConnector-{{abcdef1ghij2klmno3pqr4-111aaa-22bb-33cc-44dd-111222}}/{{111122223333}}",
        "toNumber": "+13605550199",
        "version": "0"
    }
}
```

### Amazon Chime SDK Voice Connector streaming updates
<a name="stream-update-cvc"></a>

Amazon Chime SDK Voice Connectors send this event when media streaming to Kinesis Video Streams is updated.

**Example Event data**  
The following is example data for this event.  

```
{
    "version": "0",
    "id": "{{12345678-1234-1234-1234-111122223333}}",
    "detail-type": "Chime VoiceConnector Streaming Status",
    "source": "aws.chime",
    "account": "{{111122223333}}",
    "time": "{{yyyy-mm-ddThh:mm:ssZ}}",
    "region": "us-east-1",
    "resources": [],
    "detail": {
        "callId": "{{1112-2222-4333}}",
        "updateHeaders": {
            "from": "\"{{John}}\" <sip:+{{12065550100}}@10.24.34.0>;;tag={{abcdefg}}",
            "to": "<sip:+{{13605550199@abcdef1ghij2klmno3pqr4}}.voiceconnector.chime.aws:5060>",
            "call-id": "{{1112-2222-4333}}",
            "cseq": "101 INVITE",
            "contact": "<sip:user@10.24.34.0:6090>",
            "content-type": "application/sdp",
            "content-length": "{{246}}"
        },
        "siprecMetadata": "<&xml version=\"1.0\" encoding=\"UTF-8\"&>\r\n<recording xmlns='urn:ietf:params:xml:ns:recording:1'>",
        "streamingStatus": "UPDATED",
        "transactionId": "{{12345678-1234-1234}}",
        "version": "0",
        "voiceConnectorId": "{{abcdef1ghij2klmno3pqr4}}"
    }
}
```

### Amazon Chime SDK Voice Connector streaming fails
<a name="stream-fail-cvc"></a>

Amazon Chime SDK Voice Connectors send this event when media streaming to Kinesis Video Streams fails.

**Example Event data**  
The following is example data for this event.  

```
{
  "version": "0",
  "id": "12345678-1234-1234-1234-111122223333",
  "detail-type": "Chime VoiceConnector Streaming Status",
  "source": "aws.chime",
  "account": "{{111122223333}}",
  "time": "{{yyyy-mm-ddThh:mm:ssZ}}",
  "region": "us-east-1",
  "resources": [],
  "detail": {
       "streamingStatus":"FAILED",
       "voiceConnectorId":"{{abcdefghi}}",
       "transactionId":"{{12345678-1234-1234}}",
       "callId":"{{1112-2222-4333}}",
       "direction":"Inbound",
       "failTime":"{{yyyy-mm-ddThh:mm:ssZ}}",
       "failureReason": "Internal failure",
       "version":"0"
  }
}
```