How do I set up extensions for agents to call one another directly in my Amazon Connect contact center?

7 minute read
0

I want to set up extensions so that agents in my Amazon Connect contact center can directly call one another.

Resolution

Note: Complete the following steps in the same AWS Region that your Amazon Connect instance is in.

Create a DynamoDB table that contains agent login names and their extensions

Complete the following steps:

  1. Open the Amazon DynamoDB console.
  2. On the Create DynamoDB table page enter AgenttoAgent for Table name.
  3. For Primary key, enter Extension in the Partition key panel.
  4. For Data type, choose String.
  5. Choose Create.
  6. Assign a unique extension to each agent login name.
  7. Add the extensions and agent login names to the table.
    Note: For the extensions Attribute name key, enter Extension.  For the agent login names Attribute name key, enter AgentLoginNameAgentLoginName.

Note: For more information about how to edit DynamoDB tables, see Write data to a DynamoDB table.

Create an IAM role for the Lambda function

Create an AWS Identity and Access Management (IAM) role for your AWS Lambda function. Then, attach the following policy to the role so that Lambda can find an agent's login name in DynamoDB:

{    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "dynamodb:BatchGetItem",
                "dynamodb:GetItem",
                "dynamodb:Query",
                "dynamodb:Scan",
                "dynamodb:BatchWriteItem",
                "dynamodb:PutItem",
                "dynamodb:UpdateItem"
            ],
            "Resource": "Replace with ARN of DynamoDB table you created"
        },
        {
            "Effect": "Allow",
            "Action": [
                "logs:CreateLogGroup",
                "logs:CreateLogStream",
                "logs:PutLogEvents"
            ],
            "Resource": "*"
        }
    ]
}

Create a Lambda function

Create a Lambda function. In the built-in code editor, enter the following Python code that queries the DynamoDB table with an extension input and returns the corresponding agent login name from the table:

import jsonimport boto3
from boto3.dynamodb.conditions import Key


def get_agent_id(Extension, dynamodb=None):
    if not dynamodb:
        dynamodb = boto3.resource('dynamodb')

    table = dynamodb.Table('AgenttoAgent')
    response = table.query(
        KeyConditionExpression=Key('Extension').eq(str(Extension))
    )
    return response['Items']


def lambda_handler(event, context):
    Extension = event['Details']['Parameters']['Extension']
    AgentLoginName = get_agent_id(Extension)
    for agent in AgentLoginName:
        print(agent['Extension'], ":", agent['AgentLoginName'])
        
    print(AgentLoginName)
            
    return agent

After you create the function, attach the IAM role to your function.

Add the Lambda function to your Amazon Connect instance

Complete the following steps:

  1. Open the Amazon Connect console.
  2. In the Instance alias column, choose the name of your Amazon Connect instance.
  3. In the navigation pane, choose Contact flows.
  4. In the AWS Lambda section, select the Lambda function from the Function dropdown list.
  5. Choose Add Lambda Function.
  6. Under Lambda Functions, add the function's ARN.

For more information about how to integrate Lambda with Amazon Connect, see Grant Amazon Connect access to your AWS Lambda functions.

Create a customer queue flow that checks an agent's availability to receive a call

Complete the following steps:

  1. Create a new customer queue flow
  2. Add the Check staffing block. 
  3. Choose Branch.
  4. Drag and drop the Check staffing block onto the canvas after the Entry point block.
  5. For Status to check, choose Available.
  6. Choose Save.

Note: The configured Check staffing block has three branches, True, False, and Error.

Add a "Loop prompts" block to the "True" branch of the "Check staffing" block

Complete the following steps:

  1. Choose Interact.
  2. Drag and drop a Loop prompts block onto the canvas after the Check staffing block.
  3. Connect the Loop prompts block to the True branch of the Check staffing block.
  4. Choose Loop prompts to open the block's settings menu.
  5. For Prompts, choose Text-to-speech, and then enter a prompt that's similar to "Now we will be transferring the call to $.External.AgentLoginName".
  6. Choose Add another prompt to the loop.
  7. Choose Audio recording, and then choose the music for callers to hear when they're waiting for the agent to accept the call.
  8. For Interrupt, choose the time frame for the call to time out in. For example, choose Interrupt every 1 minute.
  9. Choose Save.

Add a "Play prompts" block to the "False" and "Error" branches of the "Check staffing" block

Complete the following steps:

  1. Choose Interact.
  2. Drag and drop the Play prompts block onto the canvas after the Check staffing block.
  3. Connect the Play prompts block to the False and Error branches of the Check staffing block.
  4. Choose Play prompts to open the block's settings menu.
  5. Select Text-to-speech or chat text.
  6. In the Set manually section, enter a prompt that's similar to "The agent you are trying to reach is either not available or is busy on another call. Please try again later."
  7. Choose Save.

Add a "Disconnect / hang up" block

Complete the following steps:

  1. Choose Terminate/Transfer.
  2. Drag and drop the Disconnect / hang up block onto the canvas after the Play prompts blocks.
  3. Connect all the Timeout and Error branches to the Disconnect / hang up block and the Success branch of the Play prompts block.
  4. Choose Save
  5. Choose Publish.

Create an inbound contact flow that activates the Lambda function when an agent calls another agent's extension

  1. Create a new inbound contact flow.
  2. Choose Create contact flow to open the contact flow designer.

Note: You can add or edit blocks for your use case. For example, you can connect Error branches to the Play prompt blocks to play a custom message.

Add a Store customer input block

Complete the following steps:

  1. Choose Interact.
  2. Drag and drop a Store customer input block onto the canvas after the Entry point block.
  3. Choose Store customer input to open the block's settings menu.
  4. Select Text-to-speech, and then enter a prompt that's similar to "Please enter the agent's extension number to continue."
  5. In the Customer input section, choose Custom, and then enter the number of digits to use for each agent's extension.
  6. Choose Save.

Add an Invoke AWS Lambda function block

Complete the following steps:

  1. Choose Integrate.
  2. Drag and drop an Invoke AWS Lambda function block onto the canvas after the Store customer input block.
  3. Choose Invoke AWS Lambda function to open the block's settings.
  4. Select the Lambda function.
  5. In the Function input parameters section, choose Add a parameter, and then choose Use attribute.
  6. For Destination key, enter the Extension attribute name.
  7. For Type, choose System.
  8. For Attribute, choose Stored customer input.
  9. Choose Save.

Add a Set working queue block

Complete the following steps:

  1. Choose Set.
  2. Drag and drop a Set working queue block onto the canvas after the Invoke AWS Lambda function block.
  3. Choose Set working queue to open the block's settings menu.
  4. For Outputs, choose By agent, and then choose Use attribute.
  5. For Type, choose External.
  6. For Attribute, enter AgentLoginName.
  7. Choose Save.

Add a Set customer queue flow block

Complete the following steps:

  1. Choose Set.
  2. Drag and drop a Set customer queue flow block onto the canvas after the Set working queue block.
  3. Choose Select a flow.
  4. Choose AgentQueueFlow.
  5. Choose Save.

Add a Transfer to queue block

Complete the following steps:

  1. Choose Terminate/Transfer.
  2. Drag and drop a Transfer to queue block onto the canvas after the Set customer queue flow block.
    Note: For this use case, you don't need to configure settings for the Transfer to queue block.

Add a Disconnect / hang up block

Complete the following steps:

  1. Choose Terminate/Transfer.
  2. Drag and drop the Disconnect / hang up block onto the canvas after the Transfer to queue block.
  3. Choose Save.
  4. Choose Publish.
    Important: Make sure that you assign a phone number for agents to use to make internal calls to the AgentToAgentCall contact flow.

Create a quick connect that allows agents to use the internal calling feature

Complete the following steps:

  1. Name the quick connect InternalCalling.
  2. For Type, choose External.
  3. For Destination, enter the number that you assigned to the AgentToAgentCall contact flow.
  4. Add the InternalCalling quick connect to queues that you assigned to the agents.
    Note: The cost of each call changes depending on the call duration. For more information on pricing, see Amazon Connect pricing.

Related information

Flow block definitions in the flow designer in Amazon Connect

AWS OFFICIAL
AWS OFFICIALUpdated 23 days ago
7 Comments

Getting the below error after run the code please provide any solution or let me the json format for input with example

my json input is--- { "Extention": "1111" } in my db there is the 2 fields Table---

ExtensionAgentLoginName
1111ABC
1112XYZ

error---

{ "errorMessage": "'Details'", "errorType": "KeyError", "requestId": "cd312393-7e70-4f2e-95e4-c6f3efc0d7ee", "stackTrace": [ " File "/var/task/lambda_function.py", line 18, in lambda_handler\n Extension = event['Details']['Parameters']['Extension']\n" ] }

replied 2 years ago

Thank you for your comment. We'll review and update the Knowledge Center article as needed.

profile pictureAWS
EXPERT
replied 2 years ago

I am getting the same error on the lambda function calling the Dynamo db.... How do I resolve this.

Response { "errorMessage": "'Details'", "errorType": "KeyError", "requestId": "e3b38d1c-9bb9-4031-872f-f1427efd7941", "stackTrace": [ " File "/var/task/lambda_function.py", line 18, in lambda_handler\n Extension = event['Details']['Parameters']['Extension']\n" ] }

Function Logs START RequestId: e3b38d1c-9bb9-4031-872f-f1427efd7941 Version: 1 [ERROR] KeyError: 'Details' Traceback (most recent call last):   File "/var/task/lambda_function.py", line 18, in lambda_handler     Extension = event['Details']['Parameters']['Extension']END RequestId: e3b38d1c-9bb9-4031-872f-f1427efd7941 REPORT RequestId: e3b38d1c-9bb9-4031-872f-f1427efd7941 Duration: 39.67 ms Billed Duration: 40 ms Memory Size: 128 MB Max Memory Used: 60 MB Init Duration: 354.66 ms

replied a year ago

Resolution:

Change this statement:

Extension = event['Details']['Parameters']['Extension']

to:

Extension = event['Extension']

Worked perfectly!

replied a year ago

Thank you for your comment. We'll review and update the Knowledge Center article as needed.

profile pictureAWS
MODERATOR
replied a year ago

The JSON policy doesn't work and has a missing Principal, ARN, and Role Trust Policy Syntax Error for Resource.

replied a year ago

Thank you for your comment. We'll review and update the Knowledge Center article as needed.

profile pictureAWS
EXPERT
replied a year ago