Amazon Connect
Integrate GenerativeAgent into Amazon Connect
The Amazon Connect integration with ASAPP’s GenerativeAgent allows a caller into your Amazon Connect contact center to have a conversation with Generative Agent.
This guide demonstrates an example integration using AWS’s basic building blocks and ASAPP-provided flows. It showcases how the various components work together, but you can adapt or replace any part of the integration to match your organization’s requirements.
How it works
At a high level, the Amazon Connect integration with GenerativeAgent works by handing off the conversation between your Amazon Connect flow and GenerativeAgent:
- Hand off the conversation to GenerativeAgent through your Amazon Connect Flows.
- GenerativeAgent handles the conversation using Lambda functions to communicate with ASAPP’s APIs, and respond to the caller using AWS’s Text to Speech (TTS) service.
- Return control back to your Amazon Connect Flow when:
- The conversation is successfully completed
- The caller requests a human agent
- An error occurs
Before you Begin
Before using the GenerativeAgent integration with Amazon Connect, you need to:
-
Get your API Key Id and Secret
- Ensure your API key has been configured to access GenerativeAgent APIs. Reach out to your ASAPP team if you need access enabled.
-
Have an existing Amazon Connect Instance
- Have claimed phone numbers.
- Access to an Amazon Connect admin account.
-
AWS administrator account with the permissions for the following:
- Creating/managing IAM roles/policies: create a policy permitting list/read operations on the Kinesis Video Streams associated with the Amazon Connect Flow
- Managing Amazon Connect Instance
- Create/manage Lambda functions
- Create/manage CloudWatch Log Groups
- Create/manage ElastiCache for Redis
- Create/manage VPC
-
Be familiar with AWS including Amazon Connect, IAM roles, and more:
-
Receive the Generative Agent Connect Flow and Prompts from your ASAPP team.
The components used in the example integration are intended for testing environments, and you can use your own components in Production when you integrate GenerativeAgent.
Step 1: Set up your AWS Account and Amazon Connect Instance
You need to set up your AWS Account and configure AWS services that will be used for an Amazon Connect flow that engages GenerativeAgent. You will configure the flow in a future step.
Provide a dedicated VPC
All components of the GenerativeAgent Amazon Connect integration expect to be in the same VPC.
Ensure you have a VPC with at least two subnets in different Availability Zones
You can use an existing VPC or create a new one.
Configure your Amazon Connect Instance
You need to connect your Amazon Connect Instance with an Amazon Kinesis Video Stream Service in your AWS account.
To configure the Amazon Connect Instance, you need to:
- Navigate to Connect -> Data storage -> Live Media Storage
- Enable Live Media Streaming under Data Storage options.
- Set a retention period at minimum of 1 hour.
- Save the kinesis video stream instance prefix, it will be used as part of setting up the permissions for the IAM role.
The access to the Kinesis Video Streams service is controlled by IAM policies.
GenerativeAgent uses an IAM role in the ASAPP account to access the Kinesis Video Streams service.
Create security groups
Create security groups that you will use for communication between the Lambda functions and the ElastiCache Cluster:
- Security group for the ElastiCache Cluster
- Security group for the PullAction Lambda
- Security group for the PushAction Lambda
You will use these security groups when setting up the Lambda Functions.
Once created, you will need to configure the security groups:
- PullAction Lambda Security Group
- Outbound
- Allow TCP traffic on port 6379 to the just created ElastiCache cluster security group
- Save the security group id, it will be used when creating the PullAction Lambda.
- Outbound
- PushAction Lambda Security Group
- Outbound
- Allow TCP traffic on port 6379 to the just created ElastiCache cluster security group
- Save the security group id, it will be used when creating the PushAction Lambda.
- Outbound
- ElastiCache Security Group
- Inbound
- Allow TCP traffic on port 6379 from the just created PullAction lambda security group
- Allow TCP traffic on port 6379 from the just created PushAction lambda security group
- Save the security group id, it will be used when creating the Redis ElastiCache Cluster.
- Inbound
Redis ElastiCache Cluster
The Amazon Connect Flow uses ElastiCache Clusters in order to store ordered list of actions for each call.
To configure the ElastiCache Cluster:
- Create Subnet Group
- In ElastiCache console, create a subnet group
- Select your VPC and choose at least two subnets across different AZs
- Create the Redis Cluster
-
Choose Redis as the engine
-
Select cluster mode (disabled/enabled)
-
Pick node type based on performance requirements
The sizing is based on the amount of state that drives the memory and quantity of operations per second.
You should size it based on the expected number of calls that will use GenerativeAgent.
In this guide, we use a basic sizing. However you should test the sizing in your testing environments and size the VPC accordingly before launching to Production.
-
Choose Multi-AZ for enhanced reliability
-
Use the security group you created for the ElastiCache Cluster.
-
- Connect the ElastiCache endpoint to the ASAPP-dedicated Amazon Connect Flow
- Use the ElastiCache endpoint for all connections
- Implement connection pooling
- Save the Primary endpoint, it will be used as part of setting up the lambda functions.
This guide make suggestions on setup but the configuration is ultimately up to you.
[Learn more about Amazon ElastiCache for Redis here](https://aws.amazon.com/blogs/database/work-with-cluster-mode-on-amazon- ElastiCache-for-redis/)
Step 2: Create Lambda Functions to call GenerativeAgent
The GenerativeAgent Module expects certain Lambda functions to exist to interact with GenerativeAgent.
You will need to create the following Lambda functions:
- Engage
- PushAction
- PullAction
Lambda samples are delivered in Node.js 22.x
For other languages like Golang or Python, contact your ASAPP Team.
Engage
This lambda function sends REST API requests to ASAPP and engages GenerativeAgent into a conversation.
The sample code uses the following Environment variables:
Name | Description | Value |
---|---|---|
ASAPP_API_HOST | Base URL for ASAPP API | https://api.asapp.com |
ASAPP_API_ID | App-Id credential | Provided by ASAPP |
ASAP_API_SECRET | App-Secret credential | Provided by ASAPP |
PullAction
This lambda function is called by the Amazon Connect Flow and queries Redis for next actions in a specific call.
The call identifier is the contactId
taken from the Event.ContactData
.
Name | Description | Value |
---|---|---|
REDIS_URL | URL of the Redis cluster setup | redis://[PRIMARY_REDIS_URL] |
Use the primary endpoint created in the [Redis ElastiCache Cluster](#redis- ElastiCache-cluster) for the PRIMARY_REDIS_URL
.
PushAction
ASAPP calls this lambda function to communicate a further action for each call GenerativeAgent is engaging.
This function also pushes next actions into Redis for PullAction
to query at the next opportunity.
Save the ARN of the PushAction
lambda function, it will be used when configuring the IAM role.
Name | Description | Value |
---|---|---|
REDIS_URL | URL of the Redis cluster setup | redis://[PRIMARY_REDIS_URL] |
Use the primary endpoint created in the [Redis ElastiCache Cluster](#redis- ElastiCache-cluster) for the PRIMARY_REDIS_URL
.
Step 3: Configure IAM Roles and Policies
As part of this integration, ASAPP services will reach out to your AWS account to invoke the lambda functions and access the Kinesis Video Streams.
ASAPP will need to assume a role in your AWS account to access these services.
We will provide you with the ARN of ASAPP’s GenerativeAgent role. You need to create an IAM role for ASAPP to assume and specify the ARN of the IAM role in the trust policy.
To configure the IAM role and policies:
-
Create an IAM role with a custom trust policy:
Replace the
asapp-assuming-role-arn
placeholder with the value provided by ASAPP.If there are multiple ARNs to trust, create multiple statements with unique Sid values and ASAPP provided ARN values in each statement.
Don’t immediately add permissions, instead you will add them after creation.
-
Add Kinesis Video Stream access to the IAM role by attaching the following permissions policy:
Replace the
customer-account-id
with your AWS Account number andkinesis-video-streams-prefix
with the value saved in the Configure your Amazon Connect Instance step. -
Add Lambda Function access by attaching the following permissions policy to the IAM role. This will allow the ASAPP service to invoke lambda functions:
Replace the
lambda-pushaction-arn
placeholder with the ARN of thePushAction
lambda function. -
Share the IAM role ARN with ASAPP
ASAPP will use the ARN to interact with the
PushAction
lambda and Kinesis Video Streams.
Step 4: Add the GenerativeAgent Modules and Prompts
With the relevant components in place, you need to create or update a flow to use a GenerativeAgent Module to engage GenerativeAgent.
Upload the Prompts
The GenerativeAgent Modules uses specific prompts during the conversation. ASAPP will provide you with a set of .wav
files to be added as prompts in your Amazon Connect Instance.
Prompt modules must be named exactly as the .wav files are named so that the GenerativeAgent Module works correctly.
Create GenerativeAgent Module
The GenerativeAgent Module will handle the conversation between the customer and GenerativeAgent.
You need to create the GenerativeAgent Module in your Amazon Connect Instance:
-
Receive the GenerativeAgent module json from ASAPP.
-
Edit the json to put in the correct ARNs.
The Module will need to be updated with the correct ARNs to properly invoke the
Engage
andPushAction
lambda functions. -
Create a GenerativeAgent module.
- Within your Amazon Connect Instance, navigate to Routing > Flow > Modules.
- In the
Modules
section, click “Create flow module”. - Expand the “Save” dropdown and select “Import”.
- Upload the edited JSON file and click “Import”.
Invoke the GenerativeAgent Module
To hand off a conversation to GenerativeAgent, you need to invoke the GenerativeAgent Module.
Most companies have many flows with nuanced logic and it is entirely up to you on when you engage the GenerativeAgent Module.
Once you have determined where within your flows you want to hand off a conversation to GenerativeAgent, you need to:
-
Set GenerativeAgent Parameter
Create a “Set contact attributes” block and specify the
ASAPP_CompanyMarker
. ThisASAPP_CompanyMarker
is your company marker and must be passed to GenerativeAgent Module. -
Invoke GenerativeAgent Module
Create an “Invoke module” block and select the GenerativeAgent Module. This is where the conversation is handed off to GenerativeAgent.
Within the GenerativeAgent module, the flow will use the various components you created in previous steps to engage ASAPP’s GenerativeAgent to the end user.
Once the conversation is complete, GenerativeAgent will exit the module and return control to your flow.
-
Handle the result
The GenerativeAgent module will exit for one of three reasons, and will be output the
ASAPP_Disposition
contact attribute with one of the following values:transferToAgent
: when the conversation needs to be transferred to an agentdisengage
: when the conversation is completederror
: when an error has occurred
Step 5: Engage GenerativeAgent
Now you are ready to make a call and engage GenerativeAgent.
Call the phone number configured in your Contact Flow and follow the prompts until you reach the point where GenerativeAgent is engaged. You should see the conversation transition to GenerativeAgent based on where you placed the GenerativeAgent Module in your flow.
Verify that:
- You are handed off to GenerativeAgent
- GenerativeAgent responds appropriately to your inputs
- You are returned to your flow when the conversation ends
This integration is a good starting point for your integration with GenerativeAgent. You need to further configure the integration to meet your organization’s requirements.
Next Steps
Now that you have integrated GenerativeAgent with Amazon Connect, here are some important next steps to consider:
Configuration Overview
Learn how to configure GenerativeAgent’s behaviors, tasks, and communication style
Connect your APIs
Configure your APIs to allow GenerativeAgent to access necessary data and perform actions
Review Knowledge Base
Connect and optimize your knowledge base to improve GenerativeAgent’s responses
Go Live
Follow the deployment checklist to launch GenerativeAgent in your production environment
Was this page helpful?