Customize Amazon Connect contact flows

To start capturing audio when an agent and customer are joined in a voice conversation, customize an Agent Whisper contact flow to stream audio and send agent events to the Verint capture service.

To ensure that calls are captured, add the Start media streaming and Invoke Lambda function blocks to the Agent Whisper flow.

When these blocks are in a call contact flow other than the whisper flow, they are triggered when the customer call starts. If the customer remains in queue for more than five minutes, the call is not captured.

The following procedure demonstrates how to create a Lambda function using Javascript for node.js 20.x. A Lambda function can be implemented in any supported Lambda language. If you use a different language, environment, or version, adapt your code accordingly.

The customer is responsible for writing, deploying, testing, and maintaining the Lambda function as part of their AWS Amazon Connect environment.

Before you begin 

Create Kinesis data streams

Procedure 

  1. Enable live media streaming in your instance of Amazon Connect.

  2. Create a Lambda function that sends agent events to your Verint Recorder:

    1. From the AWS Management Console, search for Lambda.

    2. From the AWS Lambda console, in the navigation pane, choose Functions.

    3. Click the Create function button.

    4. Choose Node.js 20.x as the runtime, and choose x86_64 for Architecture.

    5. Name the function and click Create function.

    6. In the index.mjs file, replace the existing code with the following example, and then change the name of the outputStream with the name of the Kinesis Stream used for Agent Events.

      In the example code, line 16 contains the outputStream name, CallCenterStream2.

      Example:  

      Copy
      import {KinesisClient, PutRecordCommand} from '@aws-sdk/client-kinesis';
      const kinesis = new KinesisClient();

      export const handler = async (event) => {
        console.log("Received event from Amazon Connect " + JSON.stringify(event));
        const cd = event.Details?.ContactData;
        const audio = cd?.MediaStreams?.Customer?.Audio;
        if(!audio)
          return {
              statusCode: 200,
              body: JSON.stringify({ "status": "no_streams" }),
          };

        let outputStream = process.env.KINESIS_STREAM;
        if(!outputStream)
          outputStream = "CallCenterStream2";
        const data = event;

        const params = {
          Data: JSON.stringify(data),
          PartitionKey: cd.ContactId,
          StreamName: outputStream
        };
        console.log("Sending to kinesis<" + outputStream + "> event " +
            JSON.stringify(data));
        const command = new PutRecordCommand(params);
        try {
          const response = await kinesis.send(command);
          return {
              statusCode: 200,
              body: JSON.stringify({ "status": "success" }),
          };
        } catch (e) {
          if(!e.status)
            e.status = "error";
          return {
              statusCode: 200,
              body: JSON.stringify(e),
          };
        }
      };
    7. Add permissions to the Lambda function: Choose Configuration, then Permissions. Prepare or attach an existing IAM permissions policy with the permissions listed in this guide, and specify the Lambda function as the execution role.

  3. Add the Lambda function to your instance of Amazon Connect:

    1. Open the Amazon Connect console at https://console.aws.amazon.com/connect/, then on the Instances page, select the instance alias of your contact center.

    2. In the navigation pane, select Contact flows.

    3. Under AWS Lambda, add the Lambda function created in Step 2.

  4. Customize the Agent Whisper contact flow: 

    1. Using your Access URL, sign in to your Amazon Connect contact center as an administrator.

    2. In the navigation pane, select Routing, Contact flows, and then open the Agent Whisper flow or create a new one.

    3. Set a Start media streaming block.Select the Agent & Customer media tracks as shown in the screenshot below:

      Misconfiguration in the tracks can cause issues and raise alarms on the adapter receiving single-track media. If customers deliberately choose not to record both tracks, they can use the adapter's advanced configuration:

      • StreamAudioFromCustomerEnabled: value: true, default: false

      • StreamAudioToCustomerEnabled: value: true, default: false

        New image

    4. Set an Invoke AWS Lambda function block and select the custom Lambda function you created in Step 2.

      Agent Whisper contact flow set to stream to Verint Recorder

  5. Add the custom Agent Whisper flow to the call contact flows that are set to be captured.

    Contact flow set to record a call

  6. For outbound calls:

    1. Customize the Outbound whisper flow as described in step 4.

    2. Set up capturing behavior for outbound calls.

  7. For agent consultations and transfer calls:

    1. Customize the Agent Transfer flow as described in step 4.

    2. Set capturing and analytics behavior for agent transfer calls.

      image 3

What to do next 

Create an IAM role

IAM User Permissions

Add a Lambda function to your Amazon Connect instance (Amazon Connect Administrator Guide)

Invoke AWS Lambda functions from contact flows (Amazon Connect Administrator Guide)

Set up recording behavior of call contact flows (Amazon Connect Administrator Guide)