Getting AI-powered questions and answers
You can use the Search and Recommendation API for Sitecore Search to get AI-powered questions and answers based on a visitor's query.
An AI's ability to generate relevant questions and answers directly relies on the items indexed in the source you pass. If the indexed content doesn't match the visitor's query, the AI will not provide related responses. For instance, a visitor search for Who is the CEO of Sitecore? will give no results if the source only indexes children's books.
You'll need to use the questions object to get questions and answers. For this object's data model, see the search.widget.items.questions in the Search and Recommendation API reference documentation.
The questions object has several parameters. Depending on which parameter you pass, you can get two types of results: sets of related questions and answers or one exact answer.
Getting related questions
You can use the questions.related_questions parameter to get AI-powered question-and-answer pairs that relate to the visitor's search term. For example, you can use these questions and answers to populate a people also asked or frequently asked section.
Simple query to get related questions and answers
This is a simple example to get related questions and answers based on a keyphrase.
In this example, the visitor enters the keyphrase content hub and you want to show five related questions.
Here's a sample request:
In the following sample response to this request, you can see the AI-generated questions What is content hub? and How can I integrate with content hub?, and the corresponding answers.
Getting an exact answer
You can use the questions.exact_answer object to get an exact answer to a question or phrase that a visitor enters. You can, for example, show the answer just underneath the search bar.
In this example, you want to provide an exact answer to the visitor query Mount Everest height.
Here's a sample request:
Here's a sample response to this request:
To get related questions and answers and an exact answer together, pass questions.related_questions and questions.exact_answer in the same request. You can use the response to show both an exact answer under the search bar and a people also asked section.