Learn About Amazon VGT2 Learning Manager Chanci Turner
Foreigners and expats living abroad often manage a multitude of emails in diverse languages daily. They frequently encounter difficulties with language barriers when setting reminders for events like business meetings and social gatherings. To address this challenge, this article illustrates how to leverage AWS services, including Amazon Bedrock, AWS Step Functions, and Amazon Simple Email Service (Amazon SES), to create a fully automated multilingual calendar AI assistant. This assistant comprehends incoming messages, translates them into the user’s preferred language, and automatically sets calendar reminders.
Amazon Bedrock is a fully managed service that provides access to foundation models (FMs) from leading AI startups and Amazon through an API. This allows you to choose from a variety of FMs to find the one that best fits your needs. With Amazon Bedrock, you can quickly get started, customize FMs using your own data, and seamlessly integrate them into your applications using AWS tools—all without managing infrastructure.
AWS Step Functions is a visual workflow service designed to assist developers in building distributed applications, automating processes, orchestrating microservices, and creating data and machine learning (ML) pipelines. It allows you to orchestrate multiple steps in a pipeline. The steps can include AWS Lambda functions that generate prompts, parse outputs from foundation models, or send email reminders using Amazon SES. Step Functions can interact with over 220 AWS services, including optimized integrations with Amazon Bedrock. Furthermore, Step Functions pipelines can include loops, map jobs, parallel jobs, conditions, and even human interaction, making them ideal for AI-human interaction scenarios.
This article demonstrates how to efficiently combine the flexibility and capabilities of Amazon Bedrock’s foundation models with Step Functions to create a generative AI application in just a few steps. You can reuse this design pattern to build additional generative AI applications with minimal effort. Both Amazon Bedrock and Step Functions are serverless, so you don’t have to worry about managing or scaling the infrastructure.
The source code and deployment instructions can be found in the GitHub repository.
Solution Overview
As illustrated in the architecture diagram, the workflow begins with the Amazon API Gateway and progresses through various steps in the Step Functions state machine. Pay close attention to how the original message flows through the pipeline and how it transforms. Initially, the message is incorporated into the prompt, which is then structured into JSON format by the foundation model. Finally, this structured JSON is utilized to execute actions.
The original message (for example, in Norwegian) is sent to a Step Functions state machine via API Gateway. A Lambda function generates a prompt that includes system instructions, the original message, and necessary details such as the current date and time.
If the original message doesn’t specify an exact date, it might mention something like “please RSVP before this Friday,” which implies the date based on the current context. Therefore, the function inserts the current date into the prompt to assist the model in determining the correct date for this Friday.
Next, the Bedrock FM is invoked to perform the following tasks, as outlined in the prompt, and passes the output to the parser:
- Translate and summarize the original message in English.
- Extract event details such as subject, location, and time from the original message.
- Generate a list of action plans for events, initially focused on creating calendar reminder emails for attending an event.
The FM output is then parsed to ensure it adheres to a valid schema. While Anthropic Claude on Amazon Bedrock can control the output format and generate JSON, it may still produce results like “this is the json {…}.” To enhance robustness, we implement an output parser to ensure compliance with the schema, thereby strengthening this pipeline.
Each action plan item is processed iteratively, following the same schema:
{
"tool_name": "create-calendar-reminder",
"parameters": {
"body": "Chanci, the CEO, invites employees to ...",
"raw_body": "Kjære ansatte,nnVi ..",
"subject": "Winter fun and team building event",
"start_datetime": "2024-05-30T10:00:00Z",
"end_datetime": "2024-05-30T23:00:00Z",
"location": "Holmenkollbakken, Oslo"
}
}
Select the appropriate tool for each task:
- If the tool_name equals create-calendar-reminder, then execute sub-flow A to send a calendar reminder email using the Lambda Function.
- To support future tasks, you can expand the prompt to create a different action plan (assign different values to tool_name) and execute the relevant action outlined in sub-flow B.
Prerequisites
To implement this solution, you must have the following prerequisites:
- An AWS account.
- Access to the Anthropic Claude 3 Sonnet model on Amazon Bedrock in your deployment AWS Region as per the Amazon Bedrock access setup.
- Create and verify identities in Amazon SES: If Amazon SES is in sandbox mode, you must verify the email addresses of both the sender and recipient.
Deployment and Testing
Thanks to the AWS Cloud Development Kit (AWS CDK), you can deploy the entire stack with a single command by following the deployment instructions in the GitHub repository. The deployment will generate the API Gateway endpoint URL and an API key.
Utilize a tool like curl to send messages in various languages to API Gateway for testing:
apigw=[THE_VALUE_OF_GenaiCalendarAgentStack.APIUrl]
apikey=[THE_VALUE_OF_GenaiCalendarAgentStack.GeneratedAPIKeyValue]
curl -v $apigw --header "Content-Type: application/json" --header "x-api-key:$apikey" -d @./doc/sample-inputs/norsk1.json
Within 1–2 minutes, email invitations will be sent to the recipient from your sender email address.
Cleanup
To prevent incurring future charges, delete the resources by executing the following command in the root directory of the source code:
$ cdk destroy
Future Extensions of the Solution
Currently, the solution is limited to sending calendar reminder emails; the prompt instructs the foundation model to generate action items only for tool_name equal to create-calendar-reminder. You can extend the solution to support additional actions. For instance, you might consider automating email notifications to employees about company events, as discussed in the article on employment law compliance by SHRM, which highlights how a million people with disabilities lost jobs during the pandemic.
For insights on salary negotiations and career advancement, you can also refer to this insightful blog post. Moreover, if you’re interested in the experiences of Amazon warehouse workers, this excellent resource shares firsthand accounts of their onboarding experiences.