Architecture Diagram

Prerequisites
- External voice transfer connectors per account with an AWS Connect instance turned on.
- A Kore voice AI agent trained with few use cases.
Amazon Connect external voice pricing is subject to change. For more details, refer to Amazon Connect External Voice Pricing Changes document.
Set up Instructions
1. Enabling External Voice Transfer in Amazon Connect
Before setting up the integration, you must turn on the External voice systems option in your Amazon Connect instance. For more details, refer to Set up Amazon Connect external voice transfer to an on-premise voice system.- Service Quota Increase: Submit a Service Quota Increase request to Amazon Connect. Amazon Connect turns on this feature only after it approves your request.
- Accessing the Option: After approval, the External voice systems option appears in your Amazon Connect console.

2. Creating an External Voice Transfer Connector
After turning on the feature, create a connector under Voice transfer integrations to link Amazon Connect with your Voice Gateway.-
Navigate to Connector Creation: Select the External voice systems option to open the connector creation screen.

-
Connector Configuration:
- Name: Enter a name for the connector.
- Connector destination type: Select AudioCodes from the dropdown list.
- Voice system type: Select one or more options. This selection doesn’t affect functionality.
- Encryption: Select Disabled.
- Logging: Select both options to view the corresponding logs in Connector Logs.
- Host and Port Details: After creation, the connector configuration displays the IP address of the host, the protocol, and the port. This port corresponds to your Voice Gateway environment.
-
The final configuration appears as shown in the following screenshot:

3. Configuring the Amazon Connect Flow
The next step involves modifying your Amazon Connect flow to use the external voice connector you created.-
Add
Transfer to Phone Numbernode: In your Amazon Connect flow, add a Transfer to phone number node.
- Select External Voice System instead of entering a phone number.
- Attach the connector you created in the previous step.
-
Set the Resume flow after disconnect option to Yes. This ensures that after the call ends with the third-party system (Voice Gateway), the call transfers back to Amazon Connect (facilitating a continuous flow and correlation between Amazon Connect and the Kore system).

4. Configuring Contact Center AI (Kore Side Configuration)
On the Kore side, you must configure Contact Center AI (CCAI) to receive and manage calls Amazon Connect transfers.- Create New Configuration: In CCAI, create a new configuration (or use an existing one).
- Allowlist IP Address: Add the IP address that Amazon Connect provides to the allowlist. This IP address is essential for allowing communication from Amazon Connect to Kore. Check with Amazon Connect documentation or Support for the details on this IP address.
-
DID Number: Enter the Direct Inward Dialing (DID) number you specified in the Transfer to phone number node in the previous step).

- Attach to Start Flow: Once the configuration is complete, attach this number to the relevant Experience Flow within Kore.
End-to-End Call Flow
The following steps describe the call flow after this integration:-
A customer calls the Amazon Connect number.

- The Amazon Connect flow transfers the call to Voice Gateway via the external voice connector.
- CCAI handles the call. To view the call details, go to the CCAI Dashboard > Interactions section.
- After the interaction, the system transfers the call back to Amazon Connect.
Metadata Passing from Kore to Amazon Connect (Additional Feature)
Amazon Connect doesn’t support SIP header extraction. To pass metadata from Kore to Amazon Connect, use the following alternative AWS components:- API Gateway
- Lambda function
- DynamoDB Table
- CloudWatch (for debugging)
Architecture
- Create a DynamoDB table with contactId (Amazon Connect Contact Id) as a partition key.
- Create an API Gateway and call it from outside AWS via Dialog Task > Service Node in CCAI, before agent transfer, to store data in the DynamoDB table.
- To call this API, the system must pass the Amazon Connect contact ID as one of the query parameters. The system retrieves this ID from the SIP headers data that Amazon Connect sends to Kore.
- Create two Lambda functions — one for the API Gateway business logic and the other for its authentication.
- In the Amazon Connect flow, invoke another Lambda function to extract these metadata saved in DynamoDB in the last step.
- These metadata values are then set as contact attributes within the flow.
You need a three Lambda functions for this use case.
AWS Side Configuration
Create a DynamoDB Table
Name: koreCcSessions Partition Key: contactId
Create Three Lambda Functions
You must create three Lambda functions for three different purposes. Set the runtime to Python for all three. The following section lists the recommended Lambda function names and their code. After you paste the Lambda code, deploy the latest version of the code. Ensure your first and third Lambda functions have DynamoDB full access. (You can add permissions inside the IAM role of the Lambda function.)- koreStoreSessionMetadata: Use this Lambda function to expose an API Gateway (Trigger) to get the metadata from platform and store it in the DynamoDB table. Copy and deploy the code from this link.
- AuthenticateBeforeStoringInDynamoDB: Use this Lambda function to add an authentication layer (Authorizer) to the API Gateway in the previous Lambda function (koreStoreSessionMetadata). Copy and deploy the code from this link.
- koreRetrieveSessionMetadata: Amazon Connect Contact Flow invokes this Lambda function after the call disconnects from Kore and returns to Amazon Connect. This Lambda function returns all the metadata stored in the DynamoDB table using the first Lambda. Copy and deploy the code from this link.
Create an API Gateway
-
Create a REST API Gateway with the default configuration:

-
Create an API resource with the Resource path as
/kore-metadata, and then select Create resource:
-
Create an API Method with the following details:
- Method type: POST
- Integration type: Lambda function (koreStoreSessionMetadata)
- Turn on the Lambda proxy integration toggle.
- Select the Lambda function (koreStoreSessionMetadata).
- Select Create Method.

-
To authenticate this API Gateway, you need Authorizers. Create a new Authorizer with the following details:
- Authorizer name: koreClientAuth
- Authorizer type: Lambda
- Lambda function: AuthenticateBeforeStoringInDynamoDB
- Lambda event payload: Select Token
- Token source: authorizationToken
- Token validation - optional: Enter the value you want to use as Token for the API authentication. You need the same value to store in the Env Variable of AuthenticateBeforeStoringInDynamoDB Lambda function with the key as AUTH_TOKEN.
-
Select Create authorizer.


-
After creating the koreClientAuth authorizer, add this as part of authentication for the API resource and method.
- Select Edit method request.
- Select Token authorizers > koreClientAuth under Authorization.
- Select Save.

- Select Deploy API.
Modify the Contact Flow
Open the Amazon Connect instance and add the last Lambda function (koreRetrieveSessionMetadata) inside the flow.
- Name this flow as TransfertoKore&MetadataPassing. (This name appears during the Agent AI integration step.)
- Add an AWS Lambda function node after the Transfer to phone number node.
- In the AWS Lambda function:
- Select the Invoke Lambda function (koreRetrieveSessionMetadata), added in the last step.
- Add a parameter:
- Destination Key: contactId (enter this name)
- Value: set dynamically
- Namespace: System
- Key: Contact id
- Response Validation: JSON
- Save the configuration.
- Add one Set contact attribute node. In this node:
- Set attributes on: Current Contact
- Add another attribute
- Namespace: User defined
- Key:
customData - Value to be Set dynamically
- Namespace: External
- Key: body
- Save the configuration.
- Connect all the nodes. You can add a Play prompt node to check if there is any error in the flow.
- Save and Publish the flow.
The modified Amazon Connect flow appears as shown in the following screenshot:

You can also import the contact flow (.JSON file) from this link. Right-click and save it as .JSON).
Kore Side Configuration
In CCAI
-
Start Flows
- Open Conditional Flow.
-
Add the following code snippet in a Script node immediately after the Start node:
- Select Test to test the flow.
- Identify the Automation bot in Conditional Flow. Use it in the next step when configuring the Botbuilder.
-
Agent Transfer
- Go to Settings > Integrations > Agent Transfer > Voice.
- Select SIP Transfer.
- Select SIP BYE from the SIP Transfer Method list.
- Select Save to save the configuration.
In Botbuilder
Verify that the Automation bot in the CCAI Conditional Flow includes an Agent Transfer dialog task.- Open the Agent Transfer dialog task.
-
Add a Script node and paste the following code to extract contactId (Amazon Connect contact Id) from the SIP headers:
-
Add a Service node immediately after the Script node to make a REST API request to the API Gateway you configured in AWS in the earlier steps.

- Select Define Request in the Service node.
-
Add the Request URL: Add the API Gateway URL with contactId as query parameter. Get this by accessing your first Lambda function (“koreStoreSessionMetadata_S”) > Configuration > Triggers.

https://ubpl0dxgq1.execute-api.us-east-1.amazonaws.com/dev/kore-metadata?contactId={{context.session.BotUserSession.ContactId}}
- Method: POST
-
Headers:
- Content-Type: application/json
- authorizationToken: “abc123” (Add your token)

-
Body:
- Add your metadata Example:

Pass the
kore-instanceSessionId key and its value in the format as in the example above. The Agent AI widget requires this to retrieve the user’s bot history. You can also include additional data as needed.
- Save the configuration.
- Publish the bot.
Validate Your Metadata
When you call the Amazon Connect number, the call routes to Kore Automation and, after agent transfer, returns to the Amazon Connect desktop. To view the metadata, check the Flow CloudWatch logs or use Contact Search:- Sign in to Amazon Connect.
- Select Analytics and optimization > Contact search.
-
Filter the results by contact ID.

-
When you open a contact’s details, the metadata appears as contact attributes.

Passing Metadata as Custom Data to Agent AI
To integrate Agent AI as a third-party application (TPA) into the Amazon Connect workspace, follow this document.Modify the Amazon Connect flow
After integrating Agent AI as a TPA in Amazon Connect, create another contact flow (for example, KVSAgentAssist). Add this to the flow you created or imported (TransfertoKore&MetadataPassing). The following screenshot shows the completed contact flow:
customData contact attribute from Amazon Connect at runtime and passes it to the widget during its creation.
You can access this custom data in the Agent AI widget under the path: context.session.UserContext.customData.
After accepting the call and loading the Agent AI widget, you can print the custom data.
