This post is a continuation of Creating Natural Conversations with Amazon Lex QnAIntent and Amazon Bedrock Knowledge Base. In summary, we explored new capabilities available through Amazon Lex QnAIntent, powered by Amazon Bedrock, that enable you to harness natural language understanding and your own knowledge repositories to provide real-time, conversational experiences.
In many cases, Amazon Bedrock is able to generate accurate responses that meet the needs for a wide variety of questions and scenarios, using your knowledge content. However, some enterprise customers have regulatory requirements or more rigid brand guidelines, requiring certain questions to be answered verbatim with pre-approved responses. For these use cases, Amazon Lex QnAIntent provides exact match capabilities with both Amazon Kendra and Amazon OpenSearch Service knowledge bases.
In this post, we walk through how to set up and configure an OpenSearch Service cluster as the knowledge base for your Amazon Lex QnAIntent. In addition, exact match works with Amazon Kendra, and you can create an index and add frequently asked questions to your index. As detailed in Part 1 of this series, you can then select Amazon Kendra as your knowledge base under Amazon Lex QnA Configurations, provide your Amazon Kendra index ID, and select the exact match to let your bot return the exact response returned by Amazon Kendra.
Solution Overview
In the following sections, we walk through the steps to create an OpenSearch Service domain, create an OpenSearch index and populate it with documents, and test the Amazon Lex bot with QnAIntent.
Prerequisites
Before creating an OpenSearch Service cluster, you need to create an Amazon Lex V2 bot. If you don’t have an Amazon Lex V2 bot available, complete the following steps:
- On the Amazon Lex console, choose Bots in the navigation pane.
- Choose Create bot.
- Select Start with an example.
- For Example bot, choose BookTrip.
- Enter a name and description for your bot.
- Select Create a role with basic Amazon Lex permissions for your AWS Identity and Access Management (IAM) permissions runtime role.
- Select No for Is use of your bot subject to the Children’s Online Privacy Protection Act (COPPA).
- Choose Next.
- Keep all defaults in the Add Languages to Bot section.
- Choose Done to create your bot.
Create an OpenSearch Service domain
Complete the following steps to create your OpenSearch Service domain:
- On the OpenSearch Service console, choose Dashboard under Managed clusters in the navigation pane.
- Choose Create domain.
- For Domain name, enter a name for your domain (for this post, we use
my-domain
). - For Domain creation method, select Easy create.
- Under Engine options, for Version, choose the latest engine version. At the time of writing, the latest engine is OpenSearch_2.11.
- Under Network, for this post, select Public access.
- In an enterprise environment, you typically launch your OpenSearch Service cluster in a VPC.
- Under Network, select Dual-stack mode.
- Dual stack allows you to share domain resources across IPv4 and IPv6 address types, and is the recommended option.
- Under Fine-grained access control, select Create master user.
- Enter the user name and password of your choice.
- Leave all other configurations at their default settings.
- Choose Create.
It will take several minutes for your cluster to launch. When your cluster is ready, you will see a green Active status under Domain processing status.
Create an OpenSearch Service index
Complete the following steps to create an index:
- On the domain details page, copy the domain endpoint under Domain endpoint (IPv4) to use later.
- Choose the IPv4 URL link.
The IPv4 link will open the OpenSearch Dashboards login page.
- Enter the user name and password you created earlier.
- On the OpenSearch Dashboards welcome page, choose Explore on my own.
- You can dismiss or cancel any additional modals or pop-ups.
- Choose the options menu, then choose Dev Tools in the navigation pane.
- On the Dev Tools page, enter the following code to create an index, then choose the run icon to send the request:
PUT my-domain-index
{
"mappings": {
"properties": {
"question": {
"type": "text"
},
"answer": {
"type": "text"
}
}
}
}
If successful, you will see the following message:
{
"acknowledged": true,
"shards_acknowledged": true,
"index": "my-domain-index"
}
- Enter the following code to bulk index multiple documents you can use later to test:
POST _bulk
{ "index": { "_index": "my-domain-index", "_id" : "mdi00001" } }
{ "question" : "What are the check-in and check-out times?", "answer": "Check-in time is 3pm and check-out time is 11am at all FictitiousHotels locations. Early check-in and late check-out may be available upon request and availability. Please inquire at the front desk upon arrival." }
{ "index": { "_index": "my-domain-index", "_id" : "mdi00002" } }
{ "question" : "Do you offer airport shuttles?", "answer": "Airport shuttles are available at the following FictitiousHotels locations: - FictitiousHotels Dallas: Complimentary airport shuttle available to and from Dallas/Fort Worth International Airport. Shuttle runs every 30 minutes from 5am-11pm. - FictitiousHotels Chicago: Complimentary airport shuttle available to and from O'Hare International Airport and Chicago Midway Airport. Shuttle runs every hour from 5am-11pm. - FictitiousHotels San Francisco: Complimentary airport shuttle available to and from San Francisco International Airport. Shuttle runs every 30 minutes from 5am11pm. - FictitiousHotels New York: Complimentary shuttle available to and from LaGuardia Airport and JFK Airport. Shuttle runs every hour from 5am-11pm. Please contact the front desk at your FictitiousHotels location to schedule airport shuttle service at least 24 hours in advance. Shuttle services and hours may vary by location." }
{ "index": { "_index": "my-domain-index", "_id" : "mdi00003" } }
{ "question" : "Is parking available? What is the daily parking fee?", "answer": "Self-parking and valet parking are available at most FictitiousHotels locations. Daily self-parking rates range from $15-$30 per day based on location. Valet parking rates range from $25-$40 per day. Please contact your FictitiousHotels location directly for specific parking information and rates." }
{ "index": { "_index": "my-domain-index", "_id" : "mdi00004" } }
{ "question" : "4. What amenities are available at FictitiousHotels?", "answer": "Amenities available at most FictitiousHotels locations include: - Free wireless high-speed internet access - 24-hour fitness center - Outdoor pool and hot tub - 24-hour business center - On-site restaurant and bar - Room service - Laundry facilities - Concierge services - Meeting rooms and event space Specific amenities may vary by location. Contact your FictitiousHotels for details onamenities available during your stay." }
{ "index": { "_index": "my-domain-index", "_id" : "mdi00005" } }
{ "question" : "Is there an extra charge for children staying at FictitiousHotels?", "answer": "There is no extra charge for children 18 years and younger staying in the same room as their parents or guardians at FictitiousHotels locations in the United States and Canada. Rollaway beds are available for an additional $15 fee per night, subject to availability. Cribs are available free of charge on request. Please contact the front desk to request cribs or rollaway beds. Additional charges for extra occupants may apply at international FictitiousHotels locations." }
{ "index": { "_index": "my-domain-index", "_id" : "mdi00006" } }
{ "question" : "Does FictitiousHotels have a pool? What are the pool hours?", "answer": "Most FictitiousHotels locations have an outdoor pool and hot tub available for guest use. Pool hours vary by location but are generally open from 6am-10pm daily. Specific FictitiousHotels pool hours: - FictitiousHotels Miami: Pool open 24 hours - FictitiousHotels Las Vegas: Pool open 8am-8pm - FictitiousHotels Chicago: Indoor and outdoor pools, open 6am-10pm - FictitiousHotels New York: Rooftop pool, open 9am-7pm Please contact your FictitiousHotels front desk for specific pool hours during your stay. Hours may be subject to change due to weather conditions or seasonal schedules. Proper swimwear is required and no lifeguard is on duty at any time." }
{ "index": { "_index": "my-domain-index", "_id" : "mdi00007" } }
{ "question" : "Is the fitness center free for guests? What are the hours?", "answer": "Yes, access to the 24-hour fitness center is included for all FictitiousHotels guests at no extra charge. The fitness center offers a range of cardio and strength training equipment. Some locations also offer fitness classes, saunas, steam rooms, and other amenities for a fee. Please contact your FictitiousHotels for specific fitness center details. Access may be restricted to guests 18 years and older. Proper athletic attire and footwear is required." }
{ "index": { "_index": "my-domain-index", "_id" : "mdi00008" } }
{ "question" : "Does FictitiousHotels offer room service? What are the hours?", "answer": "24-hour room service is available at most FictitiousHotels locations. In-room dining menus offer a variety of breakfast, lunch, and dinner options. Hours may vary by on-site restaurants. A $5 delivery fee and 18{7df079fc2838faf5776787b4855cb970fdd91ea41b0d21e47918e41b3570aafe} service charge applies to all room service orders. For quick service, please dial extension 707 from your guest room phone. Room service hours: - FictitiousHotels San Francisco: 24-hour room service - FictitiousHotels Chicago: Room service 7am-10pm - FictitiousHotels New Orleans: Room service 7am-11pm Please contact the front desk at your FictitiousHotels location for specific room service hours and menu options. Room service availability may be limited based on on-site restaurants." }
{ "index": { "_index": "my-domain-index", "_id" : "mdi00009" } }
{ "question" : "Does FictitiousHotels provide toiletries like shampoo, soap, etc?", "answer": "Yes, each FictitiousHotels room is stocked with complimentary toiletries and bath amenities including shampoo, conditioner, soap, lotion, and bath gel. Additional amenities like toothbrushes, razors, and shaving cream are available upon request at the front desk. If any items are missing from your room, please contact housekeeping." }
{ "index": { "_index": "my-domain-index", "_id" : "mdi00010" } }
{ "question" : "How can I get extra towels or have my room cleaned?", "answer": "Fresh towels and daily housekeeping service are provided free of charge. To request extra towels or pillows, additional amenities, or to schedule midstay service, please contact the front desk by dialing 0 on your in-room phone. Daily housekeeping includes trash removal, changing sheets and towels, vacuuming, dusting, and bathroom cleaning. Just let us know your preferred service times. A Do Not Disturb sign can be placed on your door to opt out for the day." }
{ "index": { "_index": "my-domain-index", "_id" : "mdi00011" } }
{ "question" : "Does FictitiousHotels provide hair dryers in the room?", "answer": "Yes, each guest room at FictitiousHotels locations includes a hair dryer. Hair dryers are typically located in the bathroom drawer or mounted to the bathroom wall. Please contact the front desk immediately if the hair dryer is missing or malfunctioning so we can replace it." }
{ "index": { "_index": "my-domain-index", "_id" : "mdi00012" } }
{ "question" : "What type of WiFi or internet access is available at FictitiousHotels?", "answer": "Free high-speed wireless internet access is available throughout all FictitiousHotels locations. To connect, simply choose the FictitiousHotels WiFi network on your device and open a web browser. For questions or issues with connectivity, please contact the front desk for assistance. Wired internet access is also available in FictitiousHotels business centers and meeting rooms. Printers, computers, and IT support may be available for business services and events. Please inquire with your FictitiousHotels for details on business services." }
{ "index": { "_index": "my-domain-index", "_id" : "mdi00013" } }
{ "question" : "Does FictitiousHotels have electric car charging stations?", "answer": "Select FictitiousHotels locations offer electric vehicle charging stations on-site, typically located in self-parking areas. Availability varies by location. Please contact your FictitiousHotels to check availability and charging rates. Most stations offer Level 2 charging. Charging station locations include: - FictitiousHotels Portland: 2 stations - FictitiousHotels Los Angeles: 4 stations - FictitiousHotels San Francisco: 6 stations Guests can request an on-site parking spot nearest the charging stations when booking parking accommodations. Charging rates may apply." }
{ "index": { "_index": "my-domain-index", "_id" : "mdi00014" } }
{ "question" : "What is the pet policy at FictitiousHotels? Are dogs allowed?", "answer": "Pets are welcome at participating FictitiousHotels locations for an additional fee of $50 per stay. Restrictions may apply based on size, breed, or other factors. Please contact your FictitiousHotels in advance to confirm pet policies. FictitiousHotels locations in Atlanta, Austin, Chicago, Denver, Las Vegas and Seattle allow dogs under 50 lbs. Certain dog breeds may be restricted. Cats may also be permitted. Non-refundable pet fees apply. Pet owners are responsible for cleaning up after pets on hotel grounds. Pets must be attended at all times and may not be a disturbance to other guests. Pets are restricted from restaurants, lounges, fitness areas, and pool decks at all FictitiousHotels locations." }
{ "index": { "_index": "my-domain-index", "_id" : "mdi00015" } }
{ "question" : "Does FictitiousHotels have laundry facilities for guest use?", "answer": "Yes, self-service laundry facilities with washers and dryers are available for guests to use at all FictitiousHotels locations. Laundry facilities are typically located on the 2nd floor adjacent to vending machines and ice machines. Detergent is available for purchase via vending machines. The cost is $2.50 to wash and $2.50 to dry per load. Quarters can be obtained at the front desk. For any assistance with laundry services, please dial 0 and speak with the front desk. Valet laundry and dry-cleaning services may be offered for an additional fee." }
{ "index": { "_index": "my-domain-index", "_id" : "mdi00016" } }
{ "question" : "Can I request extra pillows or blankets for my FictitiousHotels room?", "answer": "Absolutely. Our housekeeping team is happy to bring additional pillows, blankets, towels and other necessities to make your stay more comfortable. We offer hypoallergenic pillows and have extra blankets available upon request. Please contact the FictitiousHotels front desk to make a special request. Dial 0 on your in-room phone. Extra amenities are subject to availability. Extra bedding must be left in the guest room at checkout to avoid additional fees." }
{ "index": { "_index": "my-domain-index", "_id" : "mdi00017" } }
{ "question" : "Does FictitiousHotels provide cribs or rollaway beds?", "answer": "Yes, cribs and rollaway beds are available upon request at all FictitiousHotels locations. Please contact the front desk as far in advance as possible to make arrangements, as these are limited in quantity. Cribs are provided complimentary as a courtesy. Rollaway beds are subject to an additional fee of $15 per night." }
{ "index": { "_index": "my-domain-index", "_id" : "mdi00018" } }
{ "question" : "What type of accessible rooms or ADA rooms does FictitiousHotels offer?", "answer": "FictitiousHotels provides accessible guest rooms tailored for those with disabilities and mobility needs. Accessible rooms feature widened doorways, lowered beds and sinks, accessible showers or tubs with grab bars, and other ADA compliant features. Please request an accessible room at the time of booking to ensure availability." }
{ "index": { "_index": "my-domain-index", "_id" : "mdi00019" } }
{ "question" : "Does FictitiousHotels provide microwaves and mini-fridges?", "answer": "Microwave and mini-refrigerator combos are available in select room types upon request and subject to availability. When booking your reservation, please inquire about availability of fridges and microwaves at your preferred FictitiousHotels location. A limited number are available. An additional $15 daily fee applies for use." }
{ "index": { "_index": "my-domain-index", "_id" : "mdi00020" } }
{ "question" : "Can I rent a conference or meeting room at FictitiousHotels?", "answer": "Yes, FictitiousHotels offers conference and meeting rooms available for rent at competitive rates. Options range from board rooms seating 8 to ballrooms accommodating up to 300 guests. State-of-the-art AV equipment is available for rent. Contact the Events Department to check availability and request a quote." }
{ "index": { "_index": "my-domain-index", "_id" : "mdi00021" } }
{ "question" : "Is there an ATM or cash machine at FictitiousHotels?", "answer": "For your convenience, ATMs are located near the front desk and lobby at all FictitiousHotels locations. The ATMs provide 24/7 access to cash in amounts up to $500 per transaction and accept all major credit and debit cards. Foreign transaction fees may apply. Please see the front desk if you need any assistance locating or using the ATM during your stay." }
{ "index": { "_index": "my-domain-index", "_id" : "mdi00022" } }
{ "question" : "Does FictitiousHotels have a spa or offer spa services?", "answer": "Select FictitiousHotels locations offer luxurious on-site spas providing massages, facials, body treatments, manicures and pedicures. For availability and booking at your FictitiousHotels, please ask the front desk for details or visit the spa directly. Day passes may be available for non-hotel guests. Additional spa access fees apply." }
{ "index": { "_index": "my-domain-index", "_id" : "mdi00023" } }
{ "question" : "Can I get a late checkout from FictitiousHotels?", "answer": "Late checkout may be available at participating FictitiousHotels locations based on availability. The standard checkout time is by 11am. Please inquire about late checkout options at check-in or contact the front desk at least 24 hours prior to your departure date to make arrangements. Late checkouts are subject to a half-day room rate charge." }
{ "index": { "_index": "my-domain-index", "_id" : "mdi00024" } }
{ "question" : "Does FictitiousHotels offer room upgrades?", "answer": "Room upgrades may be purchased upon check-in based on availability. Upgrades to suites, executive floors, or rooms with preferred views are subject to additional charges. Rates vary by date, room type, and location. Please inquire about upgrade options and pricing at the front desk during check-in. Advance reservations are recommended to guarantee upgrades." }
{ "index": { "_index": "my-domain-index", "_id" : "mdi00025" } }
{ "question" : "Do the FictitiousHotels rooms have air conditioning and heating?", "answer": "Yes, every guest room at all FictitiousHotels locations is equipped with individual climate controls allowing air conditioning or heating as desired. To operate, simply adjust the thermostat in your room. If you have any issues regulating the temperature, please contact the front desk immediately and we will send an engineer." }
{ "index": { "_index": "my-domain-index", "_id" : "mdi00026" } }
{ "question" : "Does FictitiousHotels provide wake-up call service?", "answer": "Complimentary wake-up calls are available upon request. Please contact the front desk to schedule a customized wake-up call during your stay. In-room alarm clocks are also provided for your convenience. For international locations, please specify if you need a domestic or international phone call." }
{ "index": { "_index": "my-domain-index", "_id" : "mdi00027" } }
{ "question" : "Can I smoke at FictitiousHotels? What is the smoking policy?", "answer": "For the comfort of all guests, FictitiousHotels enforces a non-smoking policy in all guest rooms and indoor public spaces. Designated outdoor smoking areas are available on-site. A minimum $200 cleaning fee will be charged for smoking detected in rooms. Smoking is prohibited by law on all hotel shuttle buses. Thank you for not smoking inside FictitiousHotels." }
{ "index": { "_index": "my-domain-index", "_id" : "mdi00028" } }
{ "question" : "Does FictitiousHotels offer child care services?", "answer": "No, we apologize that child care services are not available at FictitiousHotels locations. As an alternative, our front desk can provide recommendations for qualified local babysitting agencies and nanny services to assist families during their stay. Please let us know if you need any recommendations. Additional fees will apply." }
{ "index": { "_index": "my-domain-index", "_id" : "mdi00029" } }
{ "question" : "What restaurants are located in FictitiousHotels?", "answer": "Onsite dining options vary by location. Many FictitiousHotelss feature 24-hour cafes, coffee shops, trendy bars, steakhouses, and international cuisine. Please check with your FictitiousHotels front desk for all restaurants available on-site during your stay and operating hours. Room service is also available." }
{ "index": { "_index": "my-domain-index", "_id" : "mdi00030" } }
{ "question" : "Does FictitiousHotels provide transportation or town car service?", "answer": "FictitiousHotels can arrange transportation, car service, and limousine transfers for an additional fee. Please contact the concierge desk at least 24 hours in advance to make arrangements. We have relationships with reputable local car services and drivers. Airport shuttles, taxis, and other transportation can also be requested through your FictitiousHotels front desk." }
{ "index": { "_index": "my-domain-index", "_id" : "mdi00031" } }
{ "question" : "FictitiousHotels New York City", "answer" : "Ideally situated in Midtown Manhattan on 52nd Street, FictitiousHotels New York City positions you in the heart of the city's top attractions. This modern 25- story glass tower overlooks the bright lights of Broadway and Times Square, just minutes from your guestroom door. Inside, enjoy contemporary styling melded with classic New York flair. 345 well-appointed rooms feature plush bedding, marble bathrooms, room service, and scenic city views. On-site amenities include a state-of-the-art fitness center, business center, cocktail lounge with nightly live music, and farm-to-table restaurant serving sustainably sourced American fare. Venture outside to nearby Rockefeller Center, Radio City Music Hall, Central Park, the Museum of Modern Art and Fifth Avenue’s world-renowned shopping. Catch a Broadway show on the same block or take a short stroll to Restaurant Row’s vast culinary offerings. Grand Central Station sits under 10 minutes away." }
{ "index": { "_index": "my-domain-index", "_id" : "mdi00032" } }
{ "question" : "FictitiousHotels Chicago", "answer" : "Conveniently situated just steps from North Michigan Avenue in downtown Chicago, FictitiousHotels Chicago envelopes you in Midwestern hospitality and luxury. This sleek 50-story high rise showcases gorgeous city vistas in each of the 453 elegantly appointed guest rooms and suites. Wake up refreshed in pillowtop beds, slip into plush robes and enjoy gourmet in-room coffee service. The heated indoor pool and expansive fitness center help you stay active and refreshed, while the lobby cocktail lounge serves up local craft beers and signature cocktails. Start your day with breakfast at the Café before venturing out to the city’s top cultural attractions like the Art Institute, Millennium Park, Navy Pier and Museum Campus. Shoppers can walk just next door to Chicago’s best retail at high-end department stores and independent boutiques. Business travelers appreciate our central location and 40,000 square feet of modern event space. Enjoy easy access to Chicago’s finest dining, entertainment and more." }
{ "index": { "_index": "my-domain-index", "_id" : "mdi00033" } }
{ "question" : "FictitiousHotels Orlando", "answer" : "FictitiousHotels Orlando welcomes you with sunshine and hospitality just 3 miles from The theme parks. The resort hotel’s sprawling campus features 3 outdoor pools, 6 restaurants and lounges, full-service spa, waterpark and 27-hole championship golf course. 1,500 guestrooms cater to families and couples alike with amenities like mini-fridges, marble bathrooms, themed kids’ suites with bunk beds and separate family suites. Onsite activities range from Camp FictitiousHotels kids’ programs to poolside movies under the stars. Complimentary theme park shuttles take you directly to the theme parks and more. Area attractions like theme parks and water parks are just a short drive away. Golf fans are minutes from various golf courses. With endless recreation under the warm Florida sun, FictitiousHotels Orlando keeps the entire family entertained and happy." }
{ "index": { "_index": "my-domain-index", "_id" : "mdi00034" } }
{ "question" : "FictitiousHotels San Francisco", "answer" : "Rising over the San Francisco Bay, FictitiousHotels San Francisco treats you to panoramic waterfront views. Perched on the Embarcadero in the lively Financial District, this sleek downtown hotel blends innovative technology with California charm across 32 floors. Contemporary rooms feature voice activated controls, intuitive lighting, rainfall showers with built-in Bluetooth speakers and floor-to-ceiling windows perfect for gazing at the Bay Bridge. Sample bites from top NorCal chefs at our signature farm- to-table restaurant or sip craft cocktails beside the outdoor heated pool. Stay connected at the lobby work bar or get moving in the 24/7 fitness center. Union Square shopping sits just up the street, while iconic landmarks like the Golden Gate Bridge, Alcatraz and Fisherman's Wharf are only minutes away. Venture to Chinatown and North Beach's Italian flavors or catch a cable car straight up to Ghirardelli Square. Immerse yourself in the best of the City by the Bay." }
{ "index": { "_index": "my-domain-index", "_id" : "mdi00035" } }
{ "question" : "FictitiousHotels Honolulu", "answer" : "A true island escape awaits at FictitiousHotels Honolulu, nestled on the pristine shores of Waikiki Beach. Swaying palms frame our family-friendly resort featuring three outdoor pools, cultural activities like lei making and ukulele lessons and the island's largest lagoon waterpark. You’ll feel the spirit of ‘ohana – family – in our welcoming staff and signature Hawaiian hospitality. 1,200 newly renovated rooms open to lanais overlooking swaying palms and the sparkling blue Pacific. Five dining options include Polynesian cuisine, island-inspired plates and indulgent character breakfasts. Complimentary beach chairs and towels invite you to sunbathe on soft white sand just steps out the lobby. Take our shuttle to Pearl Harbor, historic ‘Iolani Palace or the famous North Shore. From snorkeling at Hanauma Bay to whale watching in winter, FictitiousHotels Honolulu lets you experience O’ahu's gorgeous island paradise." }
{ "index": { "_index": "my-domain-index", "_id" : "mdi00036" } }
{ "question" : "FictitiousHotels London", "answer" : "Situated in fashionable South Kensington overlooking Cromwell Road, FictitiousHotels London places you in the heart of Victorian grandeur and modern city buzz. This 19th century row house turned design hotel blends contemporary style with classic British sophistication across 210 rooms. Original touches like working fireplaces and ornate crown molding offset sleek decor and high-tech in-room tablets controlling lights, TV and 24-hour room service. Fuel up on full English breakfast and locally roasted coffee at our indoor café or unwind with afternoon tea in the English Garden. Work out in the fitness studio before indulging in an evening massage. Our concierge arranges VIP access at nearby museums and priority bookings for West End theatre. Top shopping at Harrod's and the King's Road are a quick Tube ride away. Whether here for business or pleasure, FictitiousHotels London provides five-star luxury in an unmatched location." }
If successful, you will see another message similar to that in the following screenshot.
If you want to update, delete, or add your own test documents, refer to the OpenSearch Document APIs.
Before setting up QnAIntent, make sure you have added access to the Amazon Bedrock model you intend to use.
Now that test data is populated in the OpenSearch Service domain, you can test it with the Amazon Lex bot.
Test your Amazon Lex bot
To test the bot, complete the following steps:
- On the Amazon Lex console, navigate to the QnAIntent feature of the bot you created as a prerequisite.
- Choose the language, which for this post is English (US).
- Under Generative AI Configurations, choose Configure.
- Under QnA configuration, choose Create QnA intent.
- For Intent name, enter a name (for this post,
FicticiousHotelsFAQ
). - Choose Add.
- Choose the intent you just added.
- Under QnA configuration, choose OpenSearch as the knowledge store.
- For Domain endpoint, enter the endpoint you copied earlier.
- For Index name, enter a name (for example,
my-domain-index
). - For Exact Response, select Yes.
- For Question Field, enter
question
. - For Answer Field, enter
answer
. - Choose Save intent.
Because you used the Easy create option to launch your OpenSearch Service domain, fine-grained access was enabled by default. You need to locate the Amazon Lex IAM role and add permissions to the OpenSearch Service domain to allow Amazon Lex to interact with OpenSearch Service.
- Navigate to the draft version of your bot in the navigation pane.
- Choose the link for IAM permissions runtime role.
- Copy the ARN of the role to use later.
- Navigate back to OpenSearch Dashboards.
- If you closed your browser tab or navigated away from this page, you can find this again by locating the IPv4 URL on the OpenSearch Service console from a previous step.
- On the options menu, choose Security.
- Choose Roles in the navigation pane.
- Select the role
all_access
.
- Choose Mapped users, then choose Manage mapping.
- For Backend roles, enter the IAM runtime role ARN you copied earlier.
- Choose Map.
- On the Amazon Lex console, navigate back to your bot and the English (US) language.
- Choose Build to build your bot.
- Choose Test to test your bot.
Make sure your bot has the following permissions to use QnAIntent. These permissions should be added automatically by default.
- When the Amazon Lex test chat window launches, enter a question from your sample OpenSearch Service documents, such as “What are the check-in and check-out times?”
Clean Up
In order to not incur ongoing costs, delete the resources you created as part of this post:
- Amazon Lex V2 bot
- OpenSearch Service domain
Conclusion
Amazon Lex QnAIntent provides the flexibility and choice to use a variety of different knowledge bases to generate accurate responses to questions based on your own documents and authorized knowledge sources. You can choose to let Amazon Bedrock generate a response to questions based on the results from your knowledge base, or you can generate exact response answers using Amazon Kendra or OpenSearch Service knowledge bases.
In this post, we demonstrated how to launch and configure an OpenSearch Service domain, populate an OpenSearch Service index with sample documents, and configure the exact response option using the index with Amazon Lex QnAIntent.
You can start taking advantage of Amazon Lex QnAIntent today and transform your customer experience.
About the Authors
Josh Rodgers is a Senior Solutions Architect for AWS who works with enterprise customers in the travel and hospitality vertical. Josh enjoys working with customers to solve complex problems with a focus on serverless technologies, DevOps, and security. Outside of work, Josh enjoys hiking, playing music, skydiving, painting, and spending time with family.
Thomas Rindfuss is a Sr. Solutions Architect on the Amazon Lex team. He invents, develops, prototypes, and evangelizes new technical features and solutions for language AI services that improve the customer experience and ease adoption.