---
title: "GenerateAnswer call to query the knowledgebase."
method: POST
path: "/knowledgebases/{kbId}/generateAnswer"
tags: ["Knowledgebases"]
---

# GenerateAnswer call to query the knowledgebase.

`POST /knowledgebases/{kbId}/generateAnswer`

## Path parameters

- `kbId` string, required

## Request body

- QueryDTO — POST body schema to query the knowledgebase.
  - `qnaId` string — Exact qnaId to fetch from the knowledgebase, this field takes priority over question.
  - `question` string — User question to query against the knowledge base.
  - `top` integer — Max number of answers to be returned for the question.
  - `userId` string — Unique identifier for the user. Optional parameter for telemetry. For more information, refer <a href="http://aka.ms/qnamaker-analytics#user-traffic" target="blank">Analytics and Telemetry</a>.
  - `isTest` boolean — Query against the test index.
  - `scoreThreshold` number — Threshold for answers returned based on score.
  - `context` QueryContextDTO — Context object with previous QnA's information.
    - `previousQnaId` string — Previous QnA Id - qnaId of the top result.
    - `previousUserQuery` string — Previous user query.
  - `rankerType` string — Optional field. Set to 'QuestionOnly' for using a question only Ranker.
  - `strictFilters` MetadataDTO[] — Find only answers that contain these metadata.
    - `name` string, required — Metadata name.
    - `value` string, required — Metadata value.
  - `strictFiltersCompoundOperationType` 'AND' | 'OR' — Optional field. Set to OR for using OR as Operation for Strict Filters.

## Response `200`

GenerateAnswer call response.

- QnASearchResultList — Represents List of Question Answers.
  - `answers` QnASearchResult[] — Represents Search Result list.
    - `questions` string[] — List of questions.
    - `answer` string — Answer.
    - `score` number — Search result score.
    - `id` integer — Id of the QnA result.
    - `source` string — Source of QnA result.
    - `metadata` MetadataDTO[] — List of metadata.
      - `name` string, required — Metadata name.
      - `value` string, required — Metadata value.
    - `context` ContextDTO — Context associated with Qna.
      - `isContextOnly` boolean — To mark if a prompt is relevant only with a previous question or not. true - Do not include this QnA as search result for queries without context false - ignores context and includes this QnA in search result
      - `prompts` PromptDTO[] — List of prompts associated with the answer.
        - `displayOrder` integer — Index of the prompt - used in ordering of the prompts
        - `qnaId` integer — Qna id corresponding to the prompt - if QnaId is present, QnADTO object is ignored.
        - `qna` QnADTO — Q-A object.
          - `id` integer — Unique id for the Q-A.
          - `answer` string, required — Answer text
          - `source` string — Source from which Q-A was indexed. eg. https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs
          - `questions` string[], required — List of questions associated with the answer.
          - `metadata` MetadataDTO[] — List of metadata associated with the answer.
            - `name` string, required — Metadata name.
            - `value` string, required — Metadata value.
          - `context` ContextDTO — recursive
        - `displayText` string — Text displayed to represent a follow up question prompt

## Other responses

- `default` — Error response.

## Changes

- **2019-06-24** `590ebbcfac51` — 1 info
  - api operation id `Knowledgebase_GenerateAnswer` removed and replaced with `Runtime_GenerateAnswer`

[Change history](https://skmtc.dev/azure/apis/qnamaker-runtime-client/changes/knowledgebases/:kbId/generateAnswer/post.md)

---

[API](https://skmtc.dev/azure/apis/qnamaker-runtime-client.md) · [All operations](https://skmtc.dev/azure/apis/qnamaker-runtime-client/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/azure/qnamaker-runtime-client/revisions/07212a22152e/schema)
