DEV Community

Cover image for πŸš€ "Building an Enterprise-Grade πŸ’Ό Generative AI Chatbot πŸ€– Using Amazon Q" πŸ”

πŸš€ "Building an Enterprise-Grade πŸ’Ό Generative AI Chatbot πŸ€– Using Amazon Q" πŸ”

πŸ‘‹ Hey there! I’m Sarvar, a Cloud Architect passionate about cutting-edge technologies. With years of experience in Cloud Operations (Azure and AWS), Data Operations, Data Analytics, DevOps, and GenAI I've had the privilege of working with clients around the globe, delivering top-notch results. I’m always exploring the latest tech trends and love sharing what I learn along the way. Let’s dive into the world of cloud and tech together! πŸš€

Today, we are exploring the development of an enterprise grade generative AI chatbot using Amazon Q. This Article we are focuses on creating a sophisticated and efficient chatbot designed to support employees by providing instant access to company policies, benefits, and workplace guidelines. By utilizing Amazon Q Business and leveraging company policy as a primary data source, the chatbot will streamline internal communications, ensure consistent information delivery, and enhance the overall employee experience with advanced, tailored AI technology.


Use Case:

In real-time, employees often struggle to access important information like company policies, benefits, or procedures quickly and efficiently, leading to wasted time and frustration. Our solution involves developing a GenAI chatbot using Amazon Q Business, which automates and simplifies information retrieval. The impact will be substantial: employees will receive instant, accurate answers, enhancing productivity and streamlining internal communication. Amazon Q Business will play a key role by providing powerful AI capabilities and data integration, ensuring that the chatbot can deliver relevant information seamlessly and improve overall employee experience.


Real Time Examples:

New employees often have lots of questions about company rules, like the leave policy and dress code, but finding these answers in long manuals can be frustrating and take a lot of time. For example, they might want to know how leave days are earned, if they get extra days after a year, or if unused leave can be carried forward. They may also be curious about what is allowed on casual dress days, like whether jeans are okay or if slippers are not allowed.

Our GenAI chatbot, built using Amazon Q Business, makes it easy. Instead of searching through confusing documents, new hires can simply ask the chatbot their questions, and it will give clear, real-time answers. This saves time, makes things simpler, and helps new employees get the information they need quickly and easily.

Employees often struggle to find detailed policies on allowances, incentives, or performance appraisals within lengthy HR manuals. For instance, they may have questions like, β€œHow is my travel allowance calculated?” or β€œAm I eligible for a performance-based incentive this quarter?” Searching for such answers can be tedious.

Our GenAI chatbot, powered by Amazon Q Business, solves this by providing direct, instant answers. Employees can ask the chatbot for guidance on policies like paid time off, dress code, grievance management, or safety protocols, saving time, improving efficiency, and ensuring smooth communication. This approach empowers employees, fosters engagement, and simplifies access to essential information.


Important:

Before we start, I highly recommend you go through this link to understand the basics of Amazon Q Business. I've covered all the essential points in that article, so please refer to it for a clearer understanding of how Amazon Q Business works and how it will be utilize in this tutorial.


Let's Create Amazon Q Business Application:

Creating an application in Amazon Q Business is essential for integrating and managing the AI assistant within your organization's infrastructure. This process enables you to customize the assistant's capabilities, connect it to your enterprise data sources, and define user access controls, ensuring that the AI assistant aligns with your specific business needs and security requirements.

Image description

Let's Get started

Once you click on "Create Application," you will be directed to a page where you need to provide a name for your application.

Image description

In this example, the application has been named Q-Buddy-for-Employee. Finally, select the desired outcome. Currently, the only available option is Web Experience, so choose this and proceed to the next step.

Image description

In the Access Management section, you will see two options, as shown in the image below. For this example, I have chosen IAM Identity Center, which is both recommended and set as the default by AWS. This option helps in managing users and groups effectively.

In the Quick Start user setup, you can select users and groups, as well as choose the subscription type. There are two subscription options available: Pro and Lite. If you wish to learn more about these subscription plans, please follow this link.

Image description

This is the final step in the application creation process. Here, you need to set up two critical components:

  1. Application Server Access: This requires permissions to operate on your behalf.
  2. Web Experience Settings: This step involves creating a new role necessary for the application.

Additionally, there are general settings, such as encryption, which you can adjust based on your specific requirements. Once these configurations are complete, your application setup is ready to proceed.

Image description

After creating the application, you will be directed to a page displaying all the details of your application. Here, you will find the Deployed URL, which serves as the application’s access link. Additionally, you can view details such as the users and groups associated with the application. This page also allows you to manage your application and control user access effectively.

Image description


Let's Create Data Source for Application:

In Amazon Q Business, a data source is the repository of information (e.g., databases, spreadsheets, or third-party applications) that the AI assistant uses to fetch, process, and analyze data. It is essential because it enables the assistant to provide accurate, relevant, and real-time insights or responses tailored to the organization's specific needs, ensuring a seamless and efficient user experience.

For the Data Source, we are using Amazon S3. To set this up, you need to create an S3 bucket with versioning enabled. Once the bucket is created, upload a fileβ€”in this example, an HR Policies document. The source file link for the document is provided below for reference. After successfully creating the S3 bucket and uploading the file, we will proceed with the Data Source configuration for our Amazon Q Business application.

Image description

Download the Document From here - Link

Now it's time to select the retriever for your data source. Basically, Amazon Q offers two retrievers for data sources: the first is the Native retriever, which is recommended, and the second is Amazon Kendra, as shown below.

Image description

For this tutorial, we are using the Native retriever, and for indexing, we are selecting the Starter tier, which comes with certain limitations, such as a single availability zone and a cap of 100,000 documents. I have selected 1 unit for this setup, and once you click on Confirm, the retriever for your data source will be selected.

Image description

Next, you can proceed to select the data source by clicking on Add Data Source.

Image description

Once you click on Add Data Source, you will land on the page where multiple data source options are available. For this tutorial, we are using Amazon S3 as the data source, which we have already configured in the previous steps. Simply select Amazon S3 as the data source.

Image description

After selecting Amazon S3 as the data source, provide a name for the data source along with a short description, and you are good to go.

Image description

For the IAM role, Amazon Q will automatically create the role for you. You just need to provide a name for the IAM role.

Image description

Under the Sync Scope section, specify the Amazon S3 bucket path from which the retriever will fetch the data. Leave the rest of the settings as default, and proceed to the next step.

Image description

Under Sync Mode, select Full Sync if you want to sync all the files available in your S3 bucket. If you are looking for specific files, you can select the other option, as shown below. For Frequency, I have selected On Demand to save costs since I have a single file, and I will perform a full sync whenever required. You also have the option to schedule syncs based on hours, days, or weeks.

Image description

In the last section, you will see the files. If you can see the files you have uploaded, click on Add Data Source.

Image description

Once you click on Add Data Source, you will land on the Data Source page, as shown below. Since we selected On Demand sync, we need to manually sync the data source. Click on Sync Now, and it will start syncing the data from the S3 bucket.

Image description

The syncing and indexing of your data will take time based on the size of your data. After the sync is complete, you will be able to see the Sync History status, as shown below. Congratulations! You have successfully synced the data here.

Image description


Walk through Web UI of Application:

Now we are at the final step of this tutorial, where we will log in to the Amazon Q Business UI and start testing our chatbot. To log in to the Amazon Q Business application (our generative AI chatbot), you will find a hyperlink under the Deployed Application section. Once you click on the hyperlink, it will redirect you to the generative AI chatbot's sign-in page.

Image description

The sign-in page will look like the example below. Simply provide your username, password, and MFA to log in to the application.

Image description

Welcome to the Amazon Q Business application the generative AI chatbot application. Now you can start writing your queries related to your HR and Employer.

Image description


Let's test our Employee Chatbot:

Below are a series of prompts I’ve carefully crafted based on the data we manage within Amazon S3. These prompts are designed to test our chatbot. Please note that the NASSCOM HR Manual has been used as a reference, so you may encounter mentions of "NASSCOM" in the output.

If you'd like to learn more about writing effective prompts, you can follow this Link

Prompt 0:

Summarize the guidelines on workplace safety and employee well-being.
Enter fullscreen mode Exit fullscreen mode

Output:

Image description

Prompt 1:

Explain the key HR policies from the NASSCOM HR Manual.
Enter fullscreen mode Exit fullscreen mode

Output:
Image description

Prompt 2:

A high-performing employee is consistently late for work. What actions should be taken?
Enter fullscreen mode Exit fullscreen mode

Output:

Image description

Prompt 3:

An employee believes they are not receiving the correct travel allowance. How should HR address and resolve this issue?
Enter fullscreen mode Exit fullscreen mode

Output:

Image description

Prompt 4:

During a performance appraisal, an employee disputes their evaluation score. What steps should be taken to reassess or handle this disagreement?
Enter fullscreen mode Exit fullscreen mode

Output:

Image description

Prompt 5:

What are the standard procedures for approving housing allowances?
Enter fullscreen mode Exit fullscreen mode

Output:

Image description

We have successfully tested our Amazon Q Business Chatbot, and I’m pleased to share the results. I tested a total of 5 prompts, as mentioned earlier, and all prompts received highly accurate outputs accompanied by reference links for further validation.

Key observations:

  1. Unrelated Queries: When a prompt was not related to the data, the chatbot appropriately refrained from answering, similar to how Prompt 0 behaved.
  2. Relevant but Unavailable Data: If a user query was relevant but the requested information was not present in our database, the chatbot generated a response similar to the behavior observed in Prompt 5.
  3. Fallback to General Knowledge: If users are unable to find the required information within the company’s knowledge base, they have the option to rerun the same prompt. In such cases, the chatbot will fetch a response from general knowledge sources, ensuring that the user still receives a helpful output.

These results demonstrate that the chatbot is performing as intended, effectively filtering queries and ensuring accuracy while maintaining a professional and reliable user experience.


Additional Resources You Might Like:

  1. Amazon Q Business: AI-Driven Insights for Enterprise
  2. Unlocking the Power of Prompt Engineering with Amazon Bedrock’s Foundation Model
  3. AWS Foundation Models: The Backbone of Gen AI
  4. Beyond Virtual Assistants: How Amazon Q is Reshaping Work with Generative AI

Conclusion: We have GenAI chatbot built using Amazon Q Business provides a simple and efficient way for employees, especially new joiners, to get answers about company policies, like leave and dress code, without having to dig through long, complicated manuals. By just asking the chatbot, employees receive quick, clear, and accurate responses, saving valuable time and effort. At the end of this article, we've walked through the step-by-step deployment of the Amazon Q Business application and demonstrated how we successfully implemented the generative AI chatbot. This solution streamlines communication, enhances the employee experience, and showcases the full potential of Amazon Q Business in real-world use cases.

β€” β€” β€” β€” β€” β€” β€” β€”
Here is the End!

✨ Thank you for reading! ✨ I hope this article helped simplify the process and gave you valuable insights. As I continue to explore the ever-evolving world of technology, I’m excited to share more guides, tips, and updates with you. πŸš€ Stay tuned for more content that breaks down complex concepts and makes them easier to grasp. Let’s keep learning and growing together! πŸ’‘

Top comments (1)

Collapse
 
jasondunn profile image
Jason Dunn [AWS]

Wow, great article! Super detailed. Well done.