

# Enable Amazon Connect Contact Lens integration
<a name="enable-contactlens-integration"></a>

After you create a Contact Lens connector, you need to enable the integration by assigning users security profile permissions so they can access it on the Amazon Connect admin website.

1. Log in to the Amazon Connect admin website at https://*instance name*.my.connect.aws/ using an Admin account.

1. On the navigation bar, choose **Security profiles**. On the **Manage security profiles** page, choose **Admin**, **Edit**. 

1. On the **Edit security profile** page, choose **Channels and Flows** - **AnalyticsConnectors** - **View** and **Edit** permissions, and then choose **Save**. 
**Important**  
If you don't see the Contact Lens connectors permission under **Channels and Flows**, request service quota increases for the following quotas in your Amazon Connect account:  
Contact Lens connectors per account
Maximum active recording sessions from external voice systems per instance

1. Assign this permission to the security profiles for users who you want to access the Contact Lens connectors. 
**Note**  
You can only delete the last Contact Lens connector in your Amazon Connect instance when the access to the Contact Lens connector is removed from the users of that instance.  
If you attempt to delete the last Contact Lens connector without first removing the Contact Lens connectors access from the users of that instance, the following error message is displayed: **error - Failed to delete connector \$1connector-name\$1 with error: An analytics connector permissions is being used in a security profile**.

1. After you apply the permission, users who have it will be able to see the **Contact Lens connectors** option in the Amazon Connect admin website left navigation menu, as shown in the following image.  
![\[The left menu on the Amazon Connect admin website, the Contact Lens option.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/contact-lens-connector-menuitem.png)

1. You're done enabling the Contact Lens connector. Continue to the next step: [associate a Contact Lens connector with a flow](associate-contactlens-integration.md).

# Associate a Contact Lens connector with a flow
<a name="associate-contactlens-integration"></a>

After you have [configured](configure-external-voice-system.md) your external SBC to point to the Contact Lens integration connector host, you need to configure how the audio will be processed when it reaches Amazon Connect Contact Lens. To do this, you define the audio processing steps in an Amazon Connect flow. It specifies what steps the call audio will go through, including invoking Contact Lens conversational analytics.

Complete the following steps to create a flow that enables Contact Lens, and then associate the flow with the Contact Lens connector. This flow will be invoked when the Contact Lens connector receives call audio.

1. In the Amazon Connect admin website, create a flow that uses the [Set recording and analytics behavior](set-recording-behavior.md). Configure the block to enable **Agent and customer voice recording**, **Contact Lens speech analytics**, and **Automated interaction call recording**. End the flow with the [End flow / Resume](end-flow-resume.md) block. This configuration is shown in the following image. 

   For a list of blocks you can use in a Contact Lens integration, see [Supported flow blocks for Contact Lens integration](contactlens-integration-supportedflowblocks.md).   
![\[The properties page of the Set recording behavior and analytics block.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/contactlens-connector-setblock.png)

   For detailed instructions, see [Enable conversational analytics](enable-analytics.md).

1. On the navigation menu, choose **Channels**, **Contact Lens connectors**. Choose the Contact Lens integration connector that you want to associate with the flow. In the **Flow name** field, start typing the name of your flow to display a list, and then choose the flow.   
![\[The Connectors page, a list of available flows.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/contactlens-connector-flow.png)

# Provide call metadata for Contact Lens integration
<a name="callmetadata-contactlens-integration"></a>

In Amazon Connect, each interaction with a customer is an Amazon Connect contact. Each voice session that comes through the Contact Lens connector creates an Amazon Connect contact. The connector creates an Amazon Connect contact using the fields provided in the call metadata. The call metadata includes the agent user ID and agent queue ID for the streamed call in the call metadata. 

You can provide the agent user ID and other call metadata to the Contact Lens connector by using supported SIPREC metadata parameters within the SIP INVITE of the audio stream session. The connector parses the following call metadata fields and adds this information to the Amazon Connect contact.


| Call State Field | SIPREC Metadata | Value | If not provided | 
| --- | --- | --- | --- | 
| Agent user id | AmznConnectAgentUserId | Amazon Connect agent user id | Required | 
| Queue id | AmznConnectQueueId | Amazon Connect queue id | Optional. If not provided, the default queue of the Amazon Connect instance is used. | 
| Participant order | AmznConnectParticipantOrder | Valid values: asc, desc | Optional. If not provided, ascending order is used. Amazon Connect sorts the SIPREC streams by using labels. The first stream in label order is the agent and the second is the caller. | 

A contact must have an Amazon Connect agent user ID. Contact Lens starts capturing the streamed audio, and generating call recording and call analysis, only when the agentId is provided. 

If agentid is missing then the Amazon Connect Contact Lens connector session is terminated. If your SIPREC metadata was not parsed automatically by the Amazon Connect Contact Lens connector and agent user ID is not set, you can create a flow lambda and access all the SIP and SIPREC metadata by using the following fields:


| Attribute | Description | JSONPath Reference | 
| --- | --- | --- | 
| SIPREC metadata | SIPREC metadata from the SIP event | \$1.Media.Sip.SiprecMetadata | 
| SIP header | SIP header from the SIP event. \$1SIP header name\$1 is the name of the SIP header provided in the SIP event. For example, "To", "From", and others. | \$1.Media.Sip.Headers.\$1SIP header name\$1 | 

For more information, see [Telephony call metadata attributes (call attributes)](connect-attrib-list.md#telephony-call-metadata-attributes).

## How to use event metadata
<a name="howto-correlate-eventscalls"></a>

Amazon Connect publishes SIP, streaming, and contact events. These events include the metadata gathered from the SIPREC SIP INVITE of the calls. The metadata includes the SIPREC Metadata, SIP headers, fromNumber, toNumber, and others. Here are some things you can do with this event metadata:

1. You can process the metadata in these events to determine your own unique identifier for the calls and correlate the calls with the your own system.

1.  You can then add your unique identifier for the call into the call's contact attributes by using [Set contact attributes](set-contact-attributes.md) block.

1.  You can search by custom contact attributes in the Amazon Connect admin website to find the contact for the third-party call in the two Amazon Connect instances.

For information about how to create Amazon Connect flow Lambda functions, see [Grant Amazon Connect access to your AWS Lambda functions](connect-lambda-functions.md). For a list of all the supported contact attributes that you can access in your flow Lambda, see [List of available contact attributes in Amazon Connect and their JSONPath references](connect-attrib-list.md).

# Supported flow blocks for Contact Lens integration
<a name="contactlens-integration-supportedflowblocks"></a>

The following tables list the flow blocks that you can use to specify how Amazon Connect processes the audio stream sessions. 

**Set blocks**


| Flow block | Effect | Description | 
| --- | --- | --- | 
| Set Working Queue | No Effect | Sets Working Queue | 
| Set Contact Attributes | Supported | Stores key-value pairs as contact attributes. You set a value that is later referenced in a flow. | 
| Get Queue Metrics | No Effect | Gets queue metrics | 
| Change routing priority/age | No Effect | change routing prioroty of contact | 
| Set Hold Flow | No Effect | Specifies the flow to invoke when a customer or agent is put on hold. | 
| Set Whisper Flow | No Effect | Specifies the flow to invoke when a customer or agent joined in a voice or chat conversation. | 
| Set callback Number | No Effect | Specify the attribute to set the callback number. | 
| Set Voice | No Effect | Sets the text-to-speech (TTS) language and voice to use for the contact flow. | 
| Set Customer Queue | No Effect | Sets the customer queue for customer queue flow | 
| Set Disconnect Flow | No Effect | Sets disconnect flow for disconnect queue flow | 
| Set event flow | No Effect | Specifies which flow to run during a contact event. | 
| Set routing criteria | No Effect | Sets the routing criteria for the contact. | 

**Analyze blocks**


| Flow block | Effect | Description | 
| --- | --- | --- | 
| Set Recording and Analytics behavior | Supported | Sets options for recording and enables features in Contact Lens. | 
| Set logging behavior | Supported | Enable or disable flow logs | 

**Logic blocks**


| Flow block | Effect | Description | 
| --- | --- | --- | 
| Distribute by percentage | Supported | Routes contacts randomly based on a percentage | 
| Loop | Supported | Executes looping branch for specified amount of times | 

**Branch blocks**


| Flow block | Effect | Description | 
| --- | --- | --- | 
| Check Queue Status | No Effect | Checks Queue Status | 
| Check Staffing | No Effect | Checks staffing in queues | 
| Check hours of operation | Supported | Branches based on specified hours of operation. | 
| Check Contact Attributes | Supported | Branches based on a comparison to the value of a contact attribute. | 

**Integrate blocks**


| Flow block | Effect | Description | 
| --- | --- | --- | 
| Create Task | Supported | Creates a new task manually or by leveraging a task template. | 
| Customer profiles | Supported | Enables you to retrieve, create, and update a customer profile. | 
| Invoke AWS Lambda | Supported | Calls AWS Lambda, and optionally returns key-value pairs. | 
| Invoke module | Supported | Calls a published module, which enables you create reusable sections of a contact flow. | 

**Terminate/Transfer blocks**


| Flow block | Effect | Description | 
| --- | --- | --- | 
| Disconnect/Hangup | Supported | Disconnects the contact and end the audio stream session. | 
| End Flow | Supported | Ends the current flow without disconnecting the contact. | 

# Set up multi-region redundancy for Contact Lens integration
<a name="contactlens-integration-multiregion"></a>

Multi-region redundancy enables you to scale your external voice system for highest reliability, performance, and efficiency. You can support multi-region redundancy using Amazon Connect replica instance. 

## Active/Passive redundancy configuration
<a name="contactlens-multiregion-ap"></a>

You can create one Amazon Connect instance in one Region (for example, US East (N. Virginia)) and a replica instance in another Region (for example, US West (Oregon)). You can then configure your external voice system to send SIPREC SIP INVITE to the primary Region. When the Amazon Connect instance in the primary Region fails, you can update your external voice system to failover to the replica Amazon Connect instance in the passive Region.

## Active/Active redundancy configuration
<a name="contactlens-multiregion-aa"></a>

You can implement the active-active strategy by concurrently streaming audio to both Amazon Connect instances. To implement this strategy, configure your external voice system to concurrently stream audio to the two separate Regions. In each Region, Contact Lens integration will do the following:

1. Create its own Amazon Connect contact.

1. Captures the audio stream to create call recordings

1. Perform Contact Lens analysis

This approach requires you to replicate all the Amazon Connect contact center configurations manually. However, you can use Amazon Connect Global Resiliency and it will replicate all the Amazon Connect instance settings across the Regions automatically. For more information, see [Set up Amazon Connect Global Resiliency](setup-connect-global-resiliency.md). 