Organizations spend a great deal of resources, effort, and money managing their customer service operations to answer customer questions and deliver solutions. Customers may ask questions through multiple 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.
While your organization may have the data resources needed for customer queries and responses, you may still struggle to implement an automated process to respond to your customers. Challenges may 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 these 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 match, the email is sent to the support team for a manual response.
amazon Bedrock is a fully managed service that makes Base Models (FMs) from leading ai startups and amazon available via an API, so you can choose from a wide range of FMs to find the model that best fits 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 intentions of customers when contacting customer support:
- Transaction status (e.g. status of a money transfer)
- Password reset
- Promotional or discount code
- Opening hours
- Find an agent's location
- Report fraud
- Unlock account
- Close account
Agents for amazon Bedrock can help you perform entity detection and classification in emails for these intents. In 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 that you can automate your business processes with some actions. For example, you can use Agents for amazon Bedrock to automate responding to a customer request with specific information related to that query.
Additionally, Agents for amazon Bedrock can function as an intelligent conversational interface, facilitating seamless interactions with both internal team members and external customers, efficiently addressing queries and implementing desired actions. Agents for amazon Bedrock currently supports the Anthropic Claude model and the amazon Titan Text G1 – Premier model on amazon Bedrock.
Solution Overview
To create our customer email response flow, we use the following services:
While we illustrate this use case with WorkMail, you can use another email tool that allows integration with serverless functions or webhooks to achieve similar email automation workflows. Agents for amazon Bedrock allows you to create and configure autonomous agents in your application. An agent helps your end users complete actions based on organizational data and user input. Agents orchestrate interactions between FMs, data sources, software applications, and user conversations. Additionally, agents automatically call APIs to perform 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 Claude 3 Sonnet anthropic model.
When you create your agent, you enter details to tell it what to do and how to interact with users. Instructions replace the $instructions$ placeholder in the orchestration request template.
The following is an example of instructions that we use for our use cases:
An action group defines actions that the agent can help the user perform. For example, you can define an action group named GetTransferStatus with an OpenAPI schema and an attached Lambda function. Agents for amazon Bedrock takes care of building the API based on the OpenAPI schema and performs actions using the Lambda function to get the status of 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, which triggers the subsequent workflow.
- The Lambda function seamlessly passes the email content to amazon Bedrock agents for further processing.
- The agent uses Anthropic Claude 3 Sonnet's natural language processing capabilities to understand the classification of the email content based on the predefined agent instruction settings. 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 does not correspond to a money transfer query, the agent generates an appropriate email response (for example, password reset instructions) and calls a Lambda function to facilitate delivery of the response.
- For queries related to the money transfer status, the Agent Action Group Lambda function queries the DynamoDB table for the relevant status information based on the provided transfer ID and transmits the response to the Agent.
- Using the retrieved information, the agent crafts a personalized 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 the customer's email address.
- amazon SES delivers the email message to the customer's inbox, providing seamless communication.
- In cases where the agent is unable to accurately discern the customer's intent, they escalate the issue by sending the message to a social media topic. This mechanism allows the subscribed ticketing system to receive the notification and create a support ticket for further investigation and resolution.
Prerequisites
See the README.md file in the GitHub repository to ensure that you meet the prerequisites for implementing this solution.
Implement the solution
The solution consists of three AWS Cloud Deployment Kit (AWS CDK) stacks:
- WorkmailOrg User Stack – Create the WorkMail account with domain, user and access to the inbox
- Creation of BedrockAgent – Creates the amazon Bedrock agent, agent action group, OpenAPI schema, S3 bucket, DynamoDB table, and agent group Lambda function to get DynamoDB transfer status
- Email Automation Workflow Stack – Creates the classification Lambda function that interacts with the agent and the integration Lambda function, which is integrated with WorkMail
To deploy the solution, you also need to perform some manual configurations using the AWS Management Console.
For complete instructions, see the README.md file in the GitHub repository.
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 used [email protected]). We used the following three intents on our sample data for custom classification training:
- MONEY TRANSFER – The client wants to know the status of a money transfer
- RESTORE PASSPORT – The customer has a login, account blocked or password requested
- PROMOTIONAL CODE – The customer wants to know if there is any discount or promotional code available for a money transfer
The following screenshot shows a sample email from a customer requesting the status of a money transfer.
The following screenshot shows the email received in a WorkMail inbox.
The following screenshot shows an agent response regarding the customer's query.
If the customer email is not classified, its content is forwarded to a social media topic. The following screenshot shows an example of a customer email.
The following screenshot shows the agent's response.
Whoever subscribes to the topic receives the email content as a message. We subscribe to this SNS topic with the email we passed with the human_workflow_email parameter during deployment.
Clean
To avoid incurring ongoing costs, delete the resources you created as part of this solution when you are finished. For instructions, see the README.md archive.
Conclusion
In this post, you learned how to set up an intelligent email automation solution with 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 in time and resources
- Ability to focus on key customer issues
You can extend this solution to other areas of your business and other industries. Additionally, you can use this solution to build a self-service chatbot by implementing the BedrockAgentCreation stack to answer customer or internal user queries using Agents for amazon Bedrock.
For next steps, check out Agents for amazon Bedrock to get started with its features. Follow amazon Bedrock on the AWS Machine Learning Blog to stay up to date with new amazon Bedrock capabilities and use cases.
About the author
Godwin Sahayaraj Vicente is an Enterprise Solutions Architect at AWS who is passionate about machine learning and advising customers on designing, deploying, and managing their AWS workloads and architectures. In his spare time, he loves playing cricket with his friends and tennis with his three sons.
Ramesh Kumar Venkatraman is a Senior Solutions Architect at AWS with a passion for 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 playing with his two sons and follows cricket.