DEV Community

Phạm Nguyễn Hải Anh for AWS Community Builders

Posted on • Edited on

AI HR Assistant with Amazon Bedrock Agent

Introduction

As organizations grow and evolve, so do the demands on Human Resources. Internal teams often face repetitive, time-consuming tasks—like answering common policy questions, processing leave requests, or managing onboarding queries—that can slow down productivity and strain HR capacity. An AI-powered HR assistant offers a smart, scalable solution to this challenge. This not only reduces the administrative burden on HR staff but also enhances the employee experience through quick resolution of queries and more personalized support.

This blog helps you to create an AI HR assistant that can give you internal regulations, automate the Time Leave request by using Amazon Bedrock Nova Pro model.

Architecture

Image description

Prerequisites

  1. AWS credential grants Bedrock, Lambda, S3, Athena, Glue, OpenSearch permissions
  2. Linux environment

Steps

git clone https://github.com/aws-samples/amazon-bedrock-samples.git
cd amazon-bedrock-samples/tree/main/agents-and-function-calling/bedrock-agents/use-case-examples/hr-assistant/shell
Enter fullscreen mode Exit fullscreen mode

Use the suitable model (in this blog I use Nova Pro) by editing file cfn
/hr-resources.yml
, change amazon.titan-text-premier-v1:0 to amazon.nova-pro-v1:0

Image description

Run the script:
source ./create-hr-resources.sh

Image description

Check mail:

Image description

Subscribe topic:

Image description

Once the deployment is finished. You can use the Bedrock Agent Playground:

Image description

Image description

Or you can create a web frontend with streamlit. First install streamlit:
pip install -r agents-and-function-calling/bedrock-agents/use-case-examples/hr-assistant/streamlit/requirements.txt

Image description

then cd hr-assistant/streamlit and run streamlit run agent_streamlit.py

Image description

Check history query database employee trong Athena:

Image description

Troubleshooting

Bug 1:

Bug: User: arn:aws:iam::your-account-id:user/user-name is not authorized to perform: lambda:GetLayerVersion on resource: arn:aws:lambda:us-east-1:017000801446:layer:AWSLambdaPowertoolsPythonV2:68 because no resource-based policy allows the lambda:GetLayerVersion action (Service: Lambda, Status Code: 403, ..., HandlerErrorCode: AccessDenied)
Solution: Find the line containing arn:aws:lambda:us-east-1:017000801446:layer:AWSLambdaPowertoolsPythonV2:68 in file hr-resources.yml and change the region to where you deploy.

Redeploy and bug

Bug: The script create-hr-resources.sh exits 1 and exit the terminal

Explanation: The script is created for 1 time usage as creating a database and a table. Hence when you redeploy in the same region, make sure to delete all created resources, including the CloudFormation stack. To remove the database in Athena, first delete all data in the table:

Delete table in Amazon Glue:

Image description

then run this command:

aws athena start-query-execution --query-string "DROP DATABASE employee" --result-configuration "OutputLocation=s3://<your-accound-id>--hr-resources"
Enter fullscreen mode Exit fullscreen mode

Image description

You can check the status of the query in the Athena Console:

Image description

If Status Failed, ensure database has no data.

Bug 3:

Error: Runtime.ImportModuleError: Unable to import module 'lambda.index': No module named 'requests' Traceback (most recent call last)

Solution: replace from botocore.vendored import requests (ref: https://stackoverflow.com/questions/48912253/aws-lambda-unable-to-import-module-lambda-function-no-module-named-requests)

Conclusion

Integrating an AI-powered HR assistant using Amazon Bedrock streamlines internal HR operations by automating repetitive tasks and providing instant, accurate responses to employee queries. This guide demonstrated how to deploy the solution end-to-end—from setting up resources to building a user-friendly Streamlit interface—enabling HR teams to focus on strategic initiatives while improving the employee experience. By leveraging the power of generative AI and scalable AWS services, organizations can create a more efficient, responsive, and modern HR function.

Top comments (0)