Organizations spend a lot of resources, effort, and money on running their customer care operations to answer customer questions and provide solutions. Your customers may ask questions through various channels, such as email, chat, or phone, and deploying a workforce to answer those queries can be resource intensive, time-consuming, and unproductive if the answers to those questions are repetitive.
Although your organization might have the data assets for customer queries and answers, you may still struggle to implement an automated process to reply to your customers. Challenges might include unstructured data, different languages, and a lack of expertise in artificial intelligence (AI) and machine learning (ML) technologies.
In this post, we show you how to overcome such challenges by using Amazon Bedrock to automate email responses to customer queries. With our solution, you can identify the intent of customer emails and send an automated response if the intent matches your existing knowledge base or data sources. If the intent doesn’t have a match, the email goes to the support team for a manual response.
Amazon Bedrock is a fully managed service that makes foundation models (FMs) from leading AI startups and Amazon available through an API, so you can choose from a wide range of FMs to find the model that is best suited for your use case. Amazon Bedrock offers a serverless experience so you can get started quickly, privately customize FMs with your own data, and integrate and deploy them into your applications using AWS tools without having to manage infrastructure.
The following are some common customer intents when contacting customer care:
Transaction status (for example, status of a money transfer)
Password reset
Promo code or discount
Hours of operation
Find an agent location
Report fraud
Unlock account
Close account
Agents for Amazon Bedrock can help you perform classification and entity detection on emails for these intents. For this solution, we show how to classify customer emails for the first three intents. You can also use Agents for Amazon Bedrock to detect key information from emails, so you can automate your business processes with some actions. For example, you can use Agents for Amazon Bedrock to automate the reply to a customer request with specific information related to that query.
Moreover, Agents for Amazon Bedrock can serve as an intelligent conversational interface, facilitating seamless interactions with both internal team members and external clients, efficiently addressing inquiries and implementing desired actions. Currently, Agents for Amazon Bedrock supports Anthropic Claude models and the Amazon Titan Text G1 – Premier model on Amazon Bedrock.
Solution overview
To build our customer email response flow, we use the following services:
Agents for Amazon Bedrock
Amazon DynamoDB
AWS Lambda
Amazon Simple Email Service (Amazon SES)
Amazon Simple Notification Service (Amazon SNS)
Amazon WorkMail
Although we illustrate this use case using WorkMail, you can use another email tool that allows integration with serverless functions or webhooks to accomplish similar email automation workflows. Agents for Amazon Bedrock enables you to build and configure autonomous agents in your application. An agent helps your end-users complete actions based on organization data and user input. Agents orchestrate interactions between FMs, data sources, software applications, and user conversations. In addition, agents automatically call APIs to take actions and invoke knowledge bases to supplement information for these actions. Developers can save weeks of development effort by integrating agents to accelerate the delivery of generative AI applications. For this use case, we use the Anthropic Claude 3 Sonnet model.
When you create your agent, you enter details to tell the agent what it should do and how it should interact with users. The instructions replace the $instructions$ placeholder in the orchestration prompt template.
The following is an example of instructions we used for our use cases:
An action group defines actions that the agent can help the user perform. For example, you could define an action group called GetTransferStatus with an OpenAPI schema and Lambda function attached to it. Agents for Amazon Bedrock takes care of constructing the API based on the OpenAPI schema and fulfills actions using the Lambda function to get the status from the DynamoDB money_transfer_status table.
The following architecture diagram highlights the end-to-end solution.
The solution workflow includes the following steps:
A customer initiates the process by sending an email to the dedicated customer support email address created within WorkMail.
Upon receiving the email, WorkMail invokes a Lambda function, setting the subsequent workflow in motion.
The Lambda function seamlessly relays the email content to Agents for Amazon Bedrock for further processing.
The agent employs the natural language processing capabilities of Anthropic Claude 3 Sonnet to understand the email’s content classification based on the predefined agent instruction configuration. If relevant entities are detected within the email, such as a money transfer ID, the agent invokes a Lambda function to retrieve the corresponding payment status.
If the email classification doesn’t pertain to a money transfer inquiry, the agent generates an appropriate email response (for example, password reset instructions) and calls a Lambda function to facilitate the response delivery.
For inquiries related to money transfer status, the agent action group Lambda function queries the DynamoDB table to fetch the relevant status information based on the provided transfer ID and relays the response back to the agent.
With the retrieved information, the agent crafts a tailored email response for the customer and invokes a Lambda function to initiate the delivery process.
The Lambda function uses Amazon SES to send the email response, providing the email body, subject, and customer’s email address.
Amazon SES delivers the email message to the customer’s inbox, providing seamless communication.
In scenarios where the agent can’t discern the customer’s intent accurately, it escalates the issue by pushing the message to an SNS topic. This mechanism allows subscribed ticketing system to receive the notification and create a support ticket for further investigation and resolution.
Prerequisites
Refer to the README.md file in the GitHub repo to make sure you meet the prerequisites to deploy this solution.
Deploy the solution
The solution is comprised of three AWS Cloud Deployment Kit (AWS CDK) stacks:
WorkmailOrgUserStack – Creates the WorkMail account with domain, user, and inbox access
BedrockAgentCreation – Creates the Amazon Bedrock agent, agent action group, OpenAPI schema, S3 bucket, DynamoDB table, and agent group Lambda function for getting the transfer status from DynamoDB
EmailAutomationWorkflowStack – Creates the classification Lambda function that interacts with the agent and integration Lambda function, which is integrated with WorkMail
To deploy the solution, you also perform some manual configurations using the AWS Management Console.
For full instructions, refer to the README.md file in the GitHub repo.
Test the solution
To test the solution, send an email from your personal email to the support email created as part of the AWS CDK deployment (for this post, we use support@vgs-workmail-org.awsapps.com). We use the following three intents in our sample data for custom classification training:
MONEYTRANSFER – The customer wants to know the status of a money transfer
PASSRESET – The customer has a login, account locked, or password request
PROMOCODE – The customer wants to know about a discount or promo code available for a money transfer
The following screenshot shows a sample customer email requesting the status of a money transfer.
The following screenshot shows the email received in a WorkMail inbox.
The following screenshot shows a response from the agent regarding the customer query.
If the customer email isn’t classified, the content of the email is forwarded to an SNS topic. The following screenshot shows an example customer email.
The following screenshot shows the agent response.
Whoever is subscribed to the topic receives the email content as a message. We subscribed to this SNS topic with the email that we passed with the human_workflow_email parameter during the deployment.
Clean up
To avoid incurring ongoing costs, delete the resources you created as part of this solution when you’re done. For instructions, refer to the README.md file.
Conclusion
In this post, you learned how to configure an intelligent email automation solution using Agents for Amazon Bedrock, WorkMail, Lambda, DynamoDB, Amazon SNS, and Amazon SES. This solution can provide the following benefits:
Improved email response time
Improved customer satisfaction
Cost savings regarding time and resources
Ability to focus on key customer issue
You can expand this solution to other areas in your business and to other industries. Also, you can use this solution to build a self-service chatbot by deploying the BedrockAgentCreation stack to answer customer or internal user queries using Agents for Amazon Bedrock.
As next steps, check out Agents for Amazon Bedrock to start using its features. Follow Amazon Bedrock on the AWS Machine Learning Blog to keep up to date with new capabilities and use cases for Amazon Bedrock.
About the Author
Godwin Sahayaraj Vincent is an Enterprise Solutions Architect at AWS who is passionate about Machine Learning and providing guidance to customers to design, deploy and manage their AWS workloads and architectures. In his spare time, he loves to play cricket with his friends and tennis with his three kids.
Ramesh Kumar Venkatraman is a Senior Solutions Architect at AWS who is passionate about Generative AI, Containers and Databases. He works with AWS customers to design, deploy and manage their AWS workloads and architectures. In his spare time, he loves to play with his two kids and follows cricket.