

# Use flow logs to track events in Amazon Connect flows
<a name="about-contact-flow-logs"></a>

Amazon Connect flow logs provide you with real-time details about events in your flows as customers interact with them. You can also use flow logs to help debug your flows as you are creating them. If needed, you can always [roll back](flow-version-control.md#rollback) to a previous version of a flow.

Following is an overview of logging for flows and bot interactions. 
+ **Flow logs stored in an CloudWatch group**. Use these logs for identifying bottlenecks in flow design, debugging flow issues in real-time, and analyzing customer journey patterns.

  Flow logs help you track customers between different flows by including the ID of the contact in each log entry. You can query the logs for the contact ID to trace the customer interaction through each flow.

  The CloudWatch group log is created automatically when [Enable flow logging](contact-flow-logs.md#enable-contact-flow-logs) is selected for your instance on the Amazon Connect console. However, to enable logging, you also need to add a **Set logging behavior** block to your flow. For instructions, see [Enable Amazon Connect flow logs in an Amazon CloudWatch log group](contact-flow-logs.md).
+ **Automated interaction logs**. Use these logs to analyze the quality of conversations between customers and bots, understand common customer queries, and improve bot responses.

  These logs are saved in an S3 bucket that is created when you [select](monitor-automated-interaction-logs.md) the following options for your instance on the Amazon Connect console:
  + **Enable call recording** and create or select your S3 bucket on the **Data storage** page. The automated interaction log is stored in the same S3 location as that of your call recording.
  + **Enable Automated Interaction Logs** on the **Flows** page. This option enables the logging of key interaction points such as flows, prompts, menus, and keypad selections. This automated log is available in your S3 storage and in the **Contact details** page on the Amazon Connect admin website.
  + **Enable Bot Analytics and Transcripts** in Amazon Connect on the **Flows** page. This option ensures the log includes the Amazon Lex bot transcript.

**Topics**
+ [Storage for flow logs](contact-flow-logs-stored-in-cloudwatch.md)
+ [Enable flow logs](contact-flow-logs.md)
+ [Search flow logs](search-contact-flow-logs.md)
+ [Data in flow logs](contact-flow-log-data.md)
+ [Track customers between multiple flows in your contact center](contact-flow-log-multiple-flows.md)
+ [Create alerts for events in your flow logs](contact-flow-log-alerts.md)
+ [Monitor automated interactions (IVR)](monitor-automated-interaction-logs.md)

# Flow logs stored in an Amazon CloudWatch log group
<a name="contact-flow-logs-stored-in-cloudwatch"></a>

Flow logs are stored in an Amazon CloudWatch log group, in the same AWS Region as your Amazon Connect instance. This log group is created automatically when [Enable flow logging](contact-flow-logs.md#enable-contact-flow-logs) is turned on for your instance.

For example, the following image shows the CloudWatch log groups for two test instances.

![\[The Amazon CloudWatch console, log groups, /aws/connect/mytest88 and mytest89.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/cloudwatch-log-group.png)


 A log entry added as each block in your flow is triggered. You can configure CloudWatch to send alerts when unexpected events occur during active flows. 

**What happens if my log group is deleted?** You need to manually re-create the CloudWatch log group. Otherwise, Amazon Connect won't publish more logs. 

## Pricing for flow logging
<a name="pricing-contact-flow-logs"></a>

You are not charged for generating flow logs, but you are charged for using CloudWatch for generating and storing the logs. Free tier customers are charged only for usage that exceeds service quotas. For details about Amazon CloudWatch pricing, see [Amazon CloudWatch Pricing](https://aws.amazon.com/cloudwatch/pricing/).

# Enable Amazon Connect flow logs in an Amazon CloudWatch log group
<a name="contact-flow-logs"></a>

By default when you create a new Amazon Connect instance, an Amazon CloudWatch log group is created automatically to store the logs for your instance.

**Tip**  
Amazon Connect delivers flow logs at least once. They may be delivered again for multiple reasons. For example, a service retry due to an unavoidable failure.

## Step 1: Enable logging for your instance
<a name="enable-contact-flow-logs"></a>

Use the following procedure to check that logging is enabled for your instance.

1. Open the Amazon Connect console at [https://console.aws.amazon.com/connect/](https://console.aws.amazon.com/connect/).

1. On the instances page, choose the instance alias. The instance alias is also your **instance name**, which appears in your Amazon Connect URL. The following image shows the **Amazon Connect virtual contact center instances** page, with a box around the instance alias.  
![\[The Amazon Connect virtual contact center instances page, the instance alias.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/instance.png)

1. In the navigation pane, choose **Flows**.

1. Select **Enable Flow logs** and choose **Save**.

## Step 2: Add the Set logging behavior block
<a name="use-set-logging-behavior-block"></a>

Logs are generated only for flows that include a [Set logging behavior](set-logging-behavior.md) block with logging set to enabled. 

You control which flows, or parts of flows, logs are generated for by including multiple **Set logging behavior** blocks and configuring them as needed.

When you use a **Set logging behavior** block to enable or disable logging for a flow, logging is also enabled or disabled for any subsequent flow that a contact is transferred to, even if the flow does not include a **Set logging behavior** block. To avoid logging that persists between flows, enable or disable a **Set logging behavior** block as needed for that specific flow.

**To enable or disable flow logs for a flow**

1. In the flow designer, add a [Set logging behavior](set-logging-behavior.md) block and connect it to another block in the flow.

1. Open the properties for the block. Choose **Enable** or **Disable**.

1. Choose **Save**.

1. If you add a **Set logging behavior** block to a flow that is already published, you must publish it again to start generating logs for it.

# Search flow logs stored in an Amazon CloudWatch log group
<a name="search-contact-flow-logs"></a>

Before you can search flow logs, you must first [enable flow logging](contact-flow-logs.md). 

Logs will be created for conversations that occur after logging is enabled.

**To search flow logs**

1. Open Amazon CloudWatch console, go to **Logs**, **Log groups**. The following image shows a sample log group named **mytest88**.  
![\[The Amazon CloudWatch console, log groups section.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/cloudwatch-log-group.png)

1. Choose the log group for your instance.

   A list of log streams will be displayed.

1. To search all the log streams in the instance, choose **Search log group**, as shown in the following image.  
![\[The search log group button on the /aws/connect/mytest88 page.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/contact-flow-logs-choose-search.png)

1. In the search box, enter the string you want to search for, for example, all or a portion of the contact ID. 

1. After a couple of moments (longer depending on how big your log is), Amazon CloudWatch returns results. The following image shows a sample contact ID **fb3304c2**, and the result.  
![\[The log events listed for mytest88.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/contact-flow-logs-search-results.png)

1. You can open each event to see what happened. The following image shows the event for when a **Play prompt** block runs in a flow.  
![\[The event for a Play prompt block.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/contact-flow-logs-example-event.png)

# Data in flow logs stored in an Amazon CloudWatch log group
<a name="contact-flow-log-data"></a>

Log entries for flows include details about the block associated with the log entry, the contact ID, and the action taken after the steps in the block were completed. Any contact interaction that occurs outside of the flow is not logged, such as time spent in a queue or interactions with an agent. 

You can set the properties of the block to disable logging during the parts of your flow that interact with or capture sensitive data or customers’ personal information.

If you use Amazon Lex or AWS Lambda in your flows, the logs show the entry and exit of the flow going to them, and include any information about the interaction that is sent or received during entry or exit.

Because the logs also include the flow ID, and the flow ID stays the same when you change a flow, you can use the logs to compare the interactions with different versions of the flow.

The following example log entry shows a **Set working queue** block of an inbound flow.

```
{
    "ContactId": "11111111-2222-3333-4444-555555555555",
    "ContactFlowId": "arn:aws:connect:us-west-2:0123456789012:instance/nnnnnnnnnnn-3333-4444-5555-111111111111/contact-flow/123456789000-aaaa-bbbbbbbbb-cccccccccccc",
    "ContactFlowModuleType": "SetQueue",
    "Timestamp": "2021-04-13T00:14:31.581Z",
    "Parameters": {
        "Queue": "arn:aws:connect:us-west-2:0123456789012:instance/nnnnnnnnnnn-3333-4444-5555-111111111111/queue/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
    }
}
```

# Track customers between multiple flows in your contact center
<a name="contact-flow-log-multiple-flows"></a>

In many cases, customers interact with multiple flows in your contact center, being passed from one flow to another to appropriately assist them with their specific issue. Flow logs help you track customers between different flows, by including the ID of the contact in each log entry. 

When a customer is transferred to a different flow, the ID for the contact associated with their interaction is included with the log for the new flow. You can query the logs for the contact ID to trace the customer interaction through each flow. 

In larger, high-volume contact centers, there can be multiple streams for flow logs. If a contact is transferred to a different flow, the log may be in a different stream. To make sure that you are finding all of the log data for a specific contact, you should search for the contact ID in the entire CloudWatch log group instead of in a specific log stream.

For a diagram that shows when a new contact record is created, see [Events in the contact record](about-contact-states.md#ctr-events).

# Create alerts for events in your flow logs stored in an Amazon CloudWatch log group
<a name="contact-flow-log-alerts"></a>

You can configure CloudWatch to define a filter pattern that looks for specific events in your flow logs and then creates an alert when an entry for that event is added to the log. 

For example, you can set an alert for when a flow block goes down an error path as a customer interacts with the flow. Log entries are typically available in CloudWatch within a short time, giving you near real-time notification of events in flows.

# Monitor automated interactions (IVR) in Amazon Connect
<a name="monitor-automated-interaction-logs"></a>

You can use automated interaction logs to review the automated portion of your customers' Amazon Connect experience . The interaction logs appear on the **Contact details** page. They include the following information:
+ Key interaction points, that is, flows, prompts, menus, keypad selections.
+ A full bot transcript.

 You can use the logs to monitor and improve your automated customer interactions, and maintain audio and system execution records of the interaction for compliance purposes.

## Enable automated interaction logs
<a name="enable-automated-interaction-logs"></a>

Complete the following steps to check that automated interaction logs are enabled for your Amazon Connect instance.

**Note**  
Currently, Amazon Connect doesn’t support S3 buckets with [Object Lock](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lock.html) enabled. 

1. Open the Amazon Connect console at [https://console.aws.amazon.com/connect/](https://console.aws.amazon.com/connect/).

1. Automated interactions logs are saved to the **S3 bucket you configured for call recordings**. If the call recordings feature is not yet enabled for your instance, enable it now. 

   1. On the navigation pane, choose **Data storage**, **Call recordings**, **Edit**, **Enable call recording**, and create or select your S3 bucket. 

1. In the navigation pane, choose **Flows**.

1. Select **Enable Bot Analytics and Transcripts in Amazon Connect**. Choose this option to log a full transcript of the Amazon Lex portion of the customer's experience. The transcript is then available for you to read on the **Contact details** page.

1. Select **Enable automated interaction logs**. Choose this option to log key interaction points such as flows, prompts, menus, and keypad selections. The can view the interaction log, and a listen to the audio recording if available, on the **Contact details** page.

## Permissions for automated interaction logs
<a name="permissions-automated-interaction-logs"></a>

To keep customer data secure, you can set up permissions to have granular control over who can access automated interaction logs. Access to automated interaction logs are gated by the following security profile permissions:
+ **Flows** and **Flow modules – View** permissions: These permissions are required to see flow and module specific data on the automated interaction logs.
+ **Analytics and Optimization** - **Automated interaction voice (IVR) transcripts (unredacted)** permissions: These permissions are required to access logs of the IVR interaction such as keypad inputs in response to IVR prompts, transcripts of Lex interactions, and more.

## Navigate automated interactions logs and audio recording
<a name="navigate-automated-interaction-logs"></a>

The following image shows an example of an automated interaction log on the **Contact details** page on the Amazon Connect admin website.

![\[An example of an automated interaction log.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/automated-interaction-log.png)


**To navigate the log**

1. Use tabs to toggle between the automated interaction and agent interaction to see the end-to-end interaction of your customer.

1. Choose **Show flow details** to hide system details about the flows and flow blocks.

1. Choose the flow and block hyperlinks to open the flow designer in a new tab, enabling you to quickly follow along with your flow.

1. Choose **Play** to play the specific prompt within your audio recording file. 
**Note**  
If no audio recording is available, there is no option to play the prompt.

1. Quickly see where errors have occurred including customer timeouts or Lambda function errors.

1. See where bot intents are detected and resolved.