Automate and implement model management for Amazon Kendra FAQs

Amazon Kendra is an clever search service powered by machine studying (ML). Amazon Kendra reimagines enterprise seek for your web sites and functions so your staff and clients can simply discover the content material they’re searching for, even when it’s scattered throughout a number of places and content material repositories inside your group.

Amazon Kendra FAQs permit customers to add steadily requested questions with their corresponding solutions. This helps to persistently reply frequent queries amongst end-users. As of this writing, once you need to replace FAQs, it’s essential to delete the FAQ and create it once more. On this publish, we current an easier, quicker strategy for updating your Amazon Kendra FAQs (with versioning enabled). Our methodology eliminates the handbook steps of making and deleting FAQs once you replace their contents.

Overview of answer

We use a completely deployable AWS CloudFormation template to create an Amazon Simple Storage Service (Amazon S3) bucket, which turns into the supply to retailer your Amazon Kendra FAQs. Every index-based FAQ is maintained within the folder with a prefix regarding the Amazon Kendra index.

This answer makes use of an AWS Lambda perform that will get triggered by an Amazon S3 occasion notification. Whenever you add an FAQ to the S3 folder mapped to a particular Amazon Kendra index, it creates a brand new model of the FAQ in your index. Older variations of FAQs are deleted solely after the brand new FAQ index model is created, reaching near-zero downtime of index looking out.

The next determine reveals the workflow of how our methodology creates and deletes a brand new model of an Amazon Kendra FAQ.

Architecture for Automated FAQ Update for Amazon Kendra

The workflow steps are as follows:

  1. The person uploads the Amazon Kendra FAQ doc to the S3 bucket mapped to the Amazon Kendra index.
  2. The Amazon S3 PutObject occasion triggers the Lambda perform, which reads the occasion particulars.
  3. The Lambda perform creates a brand new model of the FAQ for the goal index for every uploaded doc and deletes the older variations of the FAQ.
  4. The Lambda perform then publishes a message to Amazon Simple Notification Service (Amazon SNS), which sends an e-mail to the person notifying them that the FAQ has been efficiently up to date.


Earlier than you start the walkthrough, you want an AWS account (for those who don’t have one, you’ll be able to sign up for one). You additionally must create the information containing the pattern FAQs:

  • primary.csv – The next code is the pattern FAQ CSV template:
    What number of free clinics are in Spokane WA?, 13,
    What number of free clinics are there in Mountain View Missouri?, 7,

  • demo.json – The next code is the pattern FAQ JSON template:
      "SchemaVersion": 1,
      "FaqDocuments": [
          "Question": "How many free clinics are in Spokane WA?",
          "Answer": "13"
          "Question": "How many free clinics are there in Mountain View Missouri?",
          "Answer": "7",
          "Attributes": {
            "_source_uri": "",
            "_category": "Charitable Clinics"

  • header_demo.csv – The next code is the pattern FAQ CSV template with header:
    What number of free clinics are in Spokane WA?, 13, 2012-03-25T12:30:10+01:00
    What number of free clinics are there in Mountain View Missouri?, 7, 2012-03-25T12:30:10+01:00

Deploy the answer

The CloudFormation templates that create the sources utilized by this answer can discovered within the GitHub repository. Comply with the directions within the repository to deploy the answer. AWS CloudFormation creates the next sources in your account:

  • An S3 bucket that would be the supply for the Amazon Kendra FAQ.
  • An Amazon Kendra index.
  • An AWS Identity and Access Management (IAM) position for the Amazon Kendra FAQ to learn (GetObject) from the S3 bucket.
  • A Lambda perform that’s configured to get triggered by an Amazon S3 occasion. The perform is created outdoors of an Amazon VPC.

Word that useful resource creation can take roughly half-hour.

After you run the deployment, you’ll obtain an e-mail prompting you to substantiate the subscription on the approver e-mail deal with. Select Affirm subscription.

Amazon SNS subscription Email

You’re redirected to a web page confirming your subscription.

SNS Subscription Confirmation

Confirm that the Amazon Kendra index is listed on the Amazon Kendra console. On this publish, we named the Amazon Kendra index sample-kendra-index.

Amazon Kendra index as seen from the Amazon Kendra console

Add a pattern FAQ doc to Amazon S3

Within the earlier step, you efficiently deployed the CloudFormation stack. We use the output of the stack within the following steps:

  1. On the Outputs tab of the CloudFormation stack, word the values for S3Bucket (kendra-faq-<random-stack-id>) and KendraIndex.
    AWS CloudFormation Output
  2. On the Amazon S3 console, navigate to the S3 bucket created from the CloudFormation stack.
  3. Select Create folder and create a folder known as faq-<index-id>. For index-id, use the worth you famous for the CloudFormation parameter KendraIndex. After the folder is created, this turns into the prefix for the sample-kendra-index FAQ.
    Create S3 folder prefixed with faq
  4. Add the demo.json FAQ doc to that folder.
    Upload the demo.json FAQ document in that folder

Confirm that the index FAQ is created

To substantiate that the index FAQ is created, full the next steps:

  1. On the Amazon Kendra console, navigate to the index sample_kendra_index, which was created as a part of the deployment.
  2. Navigate to the FAQs web page for this index to examine if an FAQ is listed.

The index has the naming conference <file-name>-faq-<Date-Time>.

Resulting FAQ created by the automation solution

When the FAQ is efficiently created, you’ll obtain one other e-mail informing you about it. You could add new variations of the FAQ after you might have obtained this e-mail.

Receiving email for successful FAQ creation

Word that the automation identifies the file format that it should use whereas creating the FAQ by studying the uploaded file extension and as an exception case by the prefix of header_ for the CSV doc with a header. The goal Amazon Kendra index is recognized by the S3 bucket folder identify, which has the index ID because the suffix; for instance, faq-1f01abb8-341c-4921-ad16-139ee517a845.

Add further FAQ paperwork

Amazon Kendra FAQ helps three kinds of file format: CSV, CSV_WITH_HEADER, and JSON. Make it possible for once you add a CSV file with the header, the file identify ought to have a prefix with header_ (that is solely when utilizing the CSV file format with a header in its contents). To add your FAQ paperwork, full the next steps:

  1. Add the header_demo.csv file to the identical folder.
    Upload the heder_demo.csv FAQ document in that folder
  2. Confirm that the FAQ is created on the Amazon Kendra console.
    Verify that the FAQ is created

FAQ creation is case-sensitive to the file format of the FAQ doc that you simply add. For instance, for those who add demo.json and demo.JSON, each are handled as distinctive objects in Amazon S3. Subsequently, this motion creates two FAQs, corresponding to demo-json-faq-22-09-2022-20-09-11 and demo-JSON-faq-22-09-2022-20-09-11.

  1. Add demo.JSON.
    demo.json and demo.JSON are uploaded to the S3 bucket
  2. Confirm that the FAQ for demo.JSON is created on the Amazon Kendra console.
    Case sensitive file names result in 2 new FAQs created

Create a brand new model of the index FAQ

Now the answer is self-sufficient and capable of work independently everytime you add a brand new model of the FAQ doc in Amazon S3.

To check this, add a brand new up to date model of your demo.json FAQ doc to the faq-<index-id> folder. Whenever you navigate to the FAQ for the index, there shall be an FAQ named <file-name>-faq-<Date-Time>.

This answer creates a brand new model of the FAQ for the brand new model of the FAQ doc that was uploaded in Amazon S3. When the FAQ is energetic, it deletes the older model of the FAQ for a similar doc.

Verify that only the latest version of the FAQ exists in the index

Create an FAQ with an outline

This answer additionally helps creating an FAQ with an outline when information are named in a particular method: <document_name>-desc-<your faq description>.fileformat[json|csv]. For instance, demo-desc-hello world.json. Add this FAQ doc to the faq-<index-id> folder.

Upload the file with the description in its name to S3

After you add the doc, the FAQ shall be created and it’ll have the outline as talked about within the file identify.

FAQ created with description

It is best to solely use -desc- when it’s essential to add an outline to an FAQ. For those who add a file with the identical document_name prefix, it should delete the previous FAQ created from the document_name.fileformat FAQ doc and create a brand new FAQ with the outline.

Clear up

To scrub up, carry out the next actions:

  1. Empty the S3 bucket that was created by the CloudFormation stack to retailer the FAQ paperwork. For directions, discuss with Emptying a bucket.
  2. Delete the CloudFormation stack. For directions, discuss with Deleting a stack on the AWS CloudFormation console.


On this publish, we launched an automatic technique to handle your Amazon Kendra FAQs. After implementing this answer, it’s best to be capable of create and delete FAQs simply by importing them to an S3 bucket. This manner, you save time by avoiding repetitive handbook adjustments and troubleshooting inconsistent points which can be brought on by surprising operational incidents. You may as well audit Amazon Kendra FAQs throughout your group with confidence.

Do you might have suggestions about this publish? Submit your feedback within the feedback part. You may as well publish questions on the AWS re:Post discussion board.

In regards to the Writer

debobhadDebojit is a DevOps advisor who makes a speciality of serving to clients ship safe and dependable options utilizing AWS providers. He concentrates on infrastructure growth and constructing serverless options with AWS and DevOps. Other than work, Debojit enjoys watching films and spending time together with his household.

glennchiGlenn is a Cloud Architect at AWS. He makes use of know-how to assist clients ship on their desired outcomes of their cloud adoption journey. His present focus is DevOps and creating open-source software program.

shalabhShalabh is a Senior Guide based mostly in London. His predominant focus helps firms ship safe, dependable, and quick options utilizing AWS providers. He will get very enthusiastic about clients innovating with AWS and DevOps. Exterior of labor, Shalabh is a cricket fan and a passionate singer.

Leave a Reply

Your email address will not be published. Required fields are marked *