Organizations spend a lot of resources, effort, and money running customer care operations to answer customer questions and provide solutions. Customers may ask questions through various channels, including email, chat, and phone. Staffing to answer these questions can be resource-intensive, time-consuming, and unproductive if the answers to the questions are repetitive.
While your organization may have data assets for customer inquiries and responses, you may struggle to implement an automated process to reply to customers. Challenges include unstructured data, different languages, and lack of expertise in artificial intelligence (AI) and machine learning (ML) technologies.
In this post, we show you how to overcome these challenges by using Amazon Bedrock to automate email replies to customer inquiries. Our solution allows you to identify the intent of a customer email and send an automated response if the intent matches an existing knowledge base or data source. If the intent doesn’t match, the email is sent to your support team for a manual response.
Amazon Bedrock is a fully managed service that makes foundational models (FMs) from leading AI startups and Amazon available via APIs. You can choose from a wide range of FMs to find the best fit for your use case. Amazon Bedrock provides a serverless experience, so you can get started quickly, privately customize your FMs with your own data, and integrate and deploy them into your applications using AWS tools without having to manage any infrastructure.
Here are some common customer intents when contacting customer care:
- Transaction status (e.g. the status of a transfer)
- Reset password
- Promo Codes or Discounts
- Opening times
- Find an agent’s location
- Report a scam
- Unlock Account
- Close your account
Amazon Bedrock Agent helps with email classification and entity detection for these intents. This solution shows how to classify customer emails for the first three intents. You can also use Amazon Bedrock Agent to detect important information from emails and automate business processes with some actions. For example, you can use Amazon Bedrock Agent to automate replies to customer requests with specific information related to that query.
Additionally, Amazon Bedrock Agent acts as an intelligent conversational interface to facilitate seamless interactions with both internal team members and external clients, efficiently responding to inquiries and taking required actions.Currently, Amazon Bedrock Agent supports the Anthropic Claude and Amazon Titan Text G1 – Premier models on Amazon Bedrock.
Solution overview
To build a customer email response flow, we’ll use the following services:
This use case uses WorkMail, but you can achieve a similar email automation workflow using another email tool that allows integration with serverless functions and webhooks. Agents in Amazon Bedrock allow you to build and configure autonomous agents in your applications. Agents assist end users in completing actions based on organizational data and user input. Agents coordinate interactions between FMs, data sources, software applications, and user conversations. Additionally, agents automatically call APIs to perform actions and invoke knowledge bases to inform these actions. Developers can save weeks of development time 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 an agent, you enter details that instruct the agent on what to do and how to interact with the user. The instructions replace the $instructions$ placeholder in the orchestration prompt template.
Below are example steps we used for our use case.
An action group defines the actions that an agent can help you perform. For example, you can define an action group called GetTransferStatus with an OpenAPI schema and a Lambda function attached. The Amazon Bedrock agent will build an API based on the OpenAPI schema and perform an action to get the status from the DynamoDB money_transfer_status table using the Lambda function.
The following architecture diagram shows the end-to-end solution.
The solution workflow includes the following steps:
- Customers start the process by sending an email to a dedicated customer support email address created within WorkMail.
- When an email is received, WorkMail invokes a Lambda function to kick off the subsequent workflow.
- The Lambda function seamlessly relays the email contents to an agent in Amazon Bedrock for further processing.
- The agent uses Anthropic Claude 3 Sonnet’s natural language processing capabilities to understand the content classification of the email based on predefined agent instruction configurations. If a relevant entity, such as a remittance ID, is detected in the email, the agent invokes a Lambda function to retrieve the corresponding payment status.
- If the classification of the email does not relate to a funds transfer inquiry, the agent generates an appropriate email response (such as password reset instructions) and invokes a Lambda function to facilitate delivery of the response.
- For inquiries regarding transfer status, the Lambda function in the agent action group queries the DynamoDB table to get the relevant status information based on the provided transfer ID and returns the response to the agent.
- The agent uses the retrieved information to create a tailored email response for the customer and invokes a Lambda function to start the delivery process.
- The Lambda function uses Amazon SES to send an email response with the email body, subject, and customer email address.
- Amazon SES delivers email messages to your customers’ inboxes, making communication seamless.
- If an agent isn’t sure exactly what the customer meant, they can escalate the issue by pushing a message to an SNS topic, a mechanism by which subscribed ticketing systems can receive notifications and create a support ticket for further investigation and resolution.
Prerequisites
To ensure you have the prerequisites for deploying this solution, see the README.md file in the GitHub repository.
Deploy the solution
The solution consists of three AWS Cloud Deployment Kit (AWS CDK) stacks:
- Workmail Organization User Stack – Create a WorkMail account with domain, user and inbox access
- Bedrock Agent Creation – Create an Amazon Bedrock agent, an agent action group, an OpenAPI schema, an S3 bucket, a DynamoDB table, and an agent group Lambda function to get the transfer status from DynamoDB.
- Email Automation Workflow Stack – Create a classification Lambda function that interacts with the agent and an integration Lambda function that integrates with WorkMail.
To deploy the solution, you also perform some manual configuration using the AWS Management Console.
For detailed instructions, see the README.md file in the GitHub repository.
Test the solution
To test the solution, send an email from your personal email address to the support email address created as part of your AWS CDK deployment (this post uses support@vgs-workmail-org.awsapps.com). The sample data for custom classification training uses three intents:
- Remittance – Customers want to know the status of their remittances
- Reset Password – Customer has login, locked account or password request
- promo code – Customers want to know about discounts and promo codes available for money transfers
The following screenshot shows a sample customer email inquiring about the status of a remittance.
The following screenshot shows the email received in your WorkMail inbox.
The following screenshot shows the response from an agent to a customer inquiry.
If a customer email is not categorized, the email content is forwarded to the SNS topic. The following screenshot shows an example customer email.
The following screenshot shows the agent’s response.
Whoever subscribes to the topic will receive the email content as a message. We subscribed to this SNS topic with the email we passed in the human_workflow_email parameter during deployment.
cleaning
To avoid ongoing costs, be sure to delete the resources you created as part of this solution when you’re done. See the README.md file for instructions.
Conclusion
In this post, you learned how to use Amazon Bedrock, WorkMail, Lambda, DynamoDB, Amazon SNS, and Amazon SES agents to configure an intelligent email automation solution that provides the following benefits:
- Improved email response times
- Increase customer satisfaction
- Cost savings in terms of time and resources
- Ability to focus on key customer issues
This solution can be extended to other areas of your business or other industries.You can also use this solution to build a self-service chatbot by deploying the BedrockAgentCreation stack and using Amazon Bedrock agents to answer queries of your customers or internal users.
As a next step, check out the Amazon Bedrock agent and start using its capabilities. Follow Amazon Bedrock on the AWS Machine Learning Blog to get the latest updates on new Amazon Bedrock features and use cases.
About the Author
Godwin Sahayaraj Vincent He is an Enterprise Solutions Architect at AWS and is passionate about Machine Learning, providing guidance to customers on designing, deploying and managing workloads and architectures on AWS. In his spare time, he loves playing cricket with friends and tennis with his three children.
Ramesh Kumar Venkatraman He is a Sr. Solutions Architect at AWS and is passionate about Generative AI, Containers and Databases. He works with AWS customers to design, deploy and manage their workloads and architectures on AWS. In his spare time, he loves playing with his two kids and watching cricket.