Questions & Answers
Implementation Question & Answers

Implementing Question & Answers

If Questions & Answers is not activated for your project, you can email info@rek.ai and we will solve it quickly.

Questions & Answers are recommended in the same manner as other pages. The only difference is the addition of the data-entitytype attribute.

<div class="rek-prediction" data-entitytype="rekai-qna" data-nrofhits="5"></div>

This will result in questions being recommended along with their answers in an expandable area. The HTML structure and functionality to expand the answers are automatically created.

Högakusten

Filter which questions to display

When displaying questions, you can choose to either fetch them from a branch of the website or only from the specific page the visitor is currently on.

From a branch

When you want questions to be aggregated from a branch of the website to a collection page, you use the same parameters as for recommendations userootpath but with the data-entitytype="rekai-qna". You can also use data-subtree to specify which part of the website should be searched.

<div class="rek-prediction" data-entitytype="rekai-qna" data-nrofhits="5" data-userootpath="true"></div>

Questions from the current page

To only recommend questions created from the current page the visitor is on (excluding any children of that page, etc.), there is a dedicated data parameter: data-currentpagequestions.

<div class="rek-prediction" data-entitytype="rekai-qna" data-nrofhits="5" data-currentpagequestions="true"></div>

Filter on tags

When creating and editing questions, you can assign a "Tag" to each question. To filter by these tags, you use data-tags. If you want to show questions from more then one tag they can be comma separated.

<div class="rek-prediction" data-entitytype="rekai-qna" data-nrofhits="5" data-tags="school"></div>

Disable highlight

The text from which the question is created is automatically highlighted when a visitor clicks the link to the page from an answer. If you want to disable the highlighting function, you can do so with the parameter data-disablehighlight.

<div class="rek-prediction" data-disablehighlight="true"></div>

Create a dummy test

If you want to see dummy questions for test purpose you can use mock data

<div class="rek-prediction" data-advanced_mockdata="true" data-entitytype="rekai-qna" data-nrofhits="5"></div>

To get the question through Javascript

function myCallback(data) {
  console.log(data)
}
 
var options = {
  params: {
    entitytype:'rekai-qna'
  }
}
 
window.__rekai.predict(options, myCallback);