Knowledgebase - Update
Asynchronous operation to modify a knowledgebase.
PATCH {Endpoint}/qnamaker/v4.0/knowledgebases/{kbId}
URI Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
|
Endpoint
|
path | True |
|
Supported Cognitive Services endpoint (e.g., https://< qnamaker-resource-name> .api.cognitiveservices.azure.com). |
|
kb
|
path | True |
|
Knowledgebase id. |
Request Header
| Name | Required | Type | Description |
|---|---|---|---|
| Ocp-Apim-Subscription-Key | True |
|
Request Body
| Name | Type | Description |
|---|---|---|
| add |
An instance of CreateKbInputDTO for add operation |
|
| defaultAnswerUsedForExtraction |
|
Text string to be used as the answer in any Q-A which has no extracted answer from the document but has a hierarchy. Required when EnableHierarchicalExtraction field is set to True. |
| delete |
An instance of DeleteKbContentsDTO for delete Operation |
|
| enableHierarchicalExtraction |
|
Enable hierarchical extraction of Q-A from files and urls. The value set during KB creation will be used if this field is not present. |
| update |
An instance of UpdateKbContentsDTO for Update Operation |
Responses
| Name | Type | Description |
|---|---|---|
| 202 Accepted |
Details of the asynchronous operation. Headers
|
|
| Other Status Codes |
Error response. |
Security
Ocp-Apim-Subscription-Key
Type:
apiKey
In:
header
Examples
Successful query
Sample Request
PATCH {Endpoint}/qnamaker/v4.0/knowledgebases/9d091697-fb8c-4ed5-9ac0-35bf8273bfff
Ocp-Apim-Subscription-Key: {API key}
{
"add": {
"qnaList": [
{
"id": 0,
"answer": "You can change the default message if you use the QnAMakerDialog. See this for details: https://docs.botframework.com/en-us/azure-bot-service/templates/qnamaker/#navtitle",
"source": "Custom Editorial",
"questions": [
"How can I change the default message from QnA Maker?"
],
"metadata": []
}
],
"urls": [
"https://docs.microsoft.com/en-us/azure/cognitive-services/Emotion/FAQ"
],
"files": [
{
"fileName": "SurfaceManual.pdf",
"fileUri": "https://download.microsoft.com/download/2/9/B/29B20383-302C-4517-A006-B0186F04BE28/surface-pro-4-user-guide-EN.pdf"
}
]
},
"delete": {
"ids": [
13,
35
]
},
"update": {
"name": "QnA Maker FAQ Prompts Bot",
"qnaList": [
{
"id": 2,
"answer": "You can use our REST apis to create a KB. See here for details: https://docs.microsoft.com/en-us/rest/api/cognitiveservices/qnamaker/knowledgebase/create",
"source": "Custom Editorial",
"questions": {
"add": [],
"delete": []
},
"metadata": {
"add": [],
"delete": []
},
"context": {
"isContextOnly": false,
"promptsToAdd": [
{
"displayText": "Add Prompts",
"displayOrder": 0,
"qna": {
"id": 0,
"answer": "Click here to know more https://docs.microsoft.com/en-us/azure/cognitive-services/qnamaker/how-to/multiturn-conversation",
"source": "Editorial",
"questions": [
"How can I add prompts?"
],
"metadata": [],
"context": {
"isContextOnly": false,
"prompts": []
}
},
"qnaId": 0
},
{
"displayText": "Delete Prompts",
"displayOrder": 0,
"qna": {
"id": 0,
"answer": "Click here to know more https://docs.microsoft.com/en-us/azure/cognitive-services/qnamaker/how-to/multiturn-conversation",
"source": "Editorial",
"questions": [
"How can I delete delete prompts?"
],
"metadata": [],
"context": {
"isContextOnly": false,
"prompts": []
}
},
"qnaId": 0
},
{
"displayText": "Update Knowledgebase",
"displayOrder": 0,
"qna": null,
"qnaId": 3
}
],
"promptsToDelete": [
3
]
}
},
{
"id": 3,
"answer": "You can use our REST apis to update your KB. See here for details: https://docs.microsoft.com/en-us/rest/api/cognitiveservices/qnamaker/knowledgebase/update",
"source": "Custom Editorial",
"questions": {
"add": [],
"delete": []
},
"metadata": {
"delete": [
{
"name": "category",
"value": "api"
}
],
"add": [
{
"name": "category",
"value": "programmatic"
}
]
},
"context": {
"isContextOnly": false,
"promptsToAdd": [
{
"displayText": "Regenerate Endpoint keys",
"displayOrder": 1,
"qna": null,
"qnaId": 4
}
],
"promptsToDelete": [
4
]
}
}
]
}
}
Sample Response
{
"operationState": "NotStarted",
"createdTimestamp": "2018-03-19T07:38:46Z",
"lastActionTimestamp": "2018-03-19T07:39:29Z",
"userId": "86bb8390-56c0-42c2-9f81-3de161981191",
"operationId": "03a4f4ce-30a6-4ec6-b436-02bcdf6153e1"
}
Definitions
| Add |
An instance of CreateKbInputDTO for add operation |
| Context |
Context of a QnA |
| Delete |
An instance of DeleteKbContentsDTO for delete Operation |
| Error |
The error object. As per Microsoft One API guidelines - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. |
|
Error |
One of a server-defined set of error codes. |
|
Error |
Error response. As per Microsoft One API guidelines - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. |
| FileDTO |
DTO to hold details of uploaded files. |
|
Inner |
An object containing more specific information about the error. As per Microsoft One API guidelines - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. |
| Metadata |
List of metadata associated with the answer to be updated |
| MetadataDTO |
Name - value pair of metadata. |
| Operation |
Record to track long running operation. |
|
Operation |
Operation state. |
| PromptDTO |
Prompt for an answer. |
| Qna |
QnADTO - Either QnaId or QnADTO needs to be present in a PromptDTO object |
| QnADTO |
Q-A object. |
| Questions |
List of questions associated with the answer. |
| Update |
An instance of UpdateKbContentsDTO for Update Operation |
|
Update |
Contains list of QnAs to be updated |
|
Update |
PATCH Body schema for Update Qna List |
Add
An instance of CreateKbInputDTO for add operation
| Name | Type | Description |
|---|---|---|
| files |
|
List of files to be added to knowledgebase. |
| qnaList |
|
List of QNA to be added to the index. Ids are generated by the service and should be omitted. |
| urls |
|
List of URLs to be added to knowledgebase. |
Context
Context of a QnA
| Name | Type | Description |
|---|---|---|
| isContextOnly |
|
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 |
List of prompts associated with the answer. |
Delete
An instance of DeleteKbContentsDTO for delete Operation
| Name | Type | Description |
|---|---|---|
| ids |
|
List of Qna Ids to be deleted |
| sources |
|
List of sources to be deleted from knowledgebase. |
Error
The error object. As per Microsoft One API guidelines - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses.
| Name | Type | Description |
|---|---|---|
| code |
One of a server-defined set of error codes. |
|
| details |
|
An array of details about specific errors that led to this reported error. |
| innerError |
An object containing more specific information than the current object about the error. |
|
| message |
|
A human-readable representation of the error. |
| target |
|
The target of the error. |
ErrorCodeType
One of a server-defined set of error codes.
| Name | Type | Description |
|---|---|---|
| BadArgument |
|
|
| EndpointKeysError |
|
|
| ExtractionFailure |
|
|
| Forbidden |
|
|
| KbNotFound |
|
|
| NotFound |
|
|
| OperationNotFound |
|
|
| QnaRuntimeError |
|
|
| QuotaExceeded |
|
|
| SKULimitExceeded |
|
|
| ServiceError |
|
|
| Unauthorized |
|
|
| Unspecified |
|
|
| ValidationFailure |
|
ErrorResponse
Error response. As per Microsoft One API guidelines - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses.
| Name | Type | Description |
|---|---|---|
| error |
The error object. |
FileDTO
DTO to hold details of uploaded files.
| Name | Type | Description |
|---|---|---|
| fileName |
|
File name. Supported file types are ".tsv", ".pdf", ".txt", ".docx", ".xlsx". |
| fileUri |
|
Public URI of the file. |
InnerErrorModel
An object containing more specific information about the error. As per Microsoft One API guidelines - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses.
| Name | Type | Description |
|---|---|---|
| code |
|
A more specific error code than was provided by the containing error. |
| innerError |
An object containing more specific information than the current object about the error. |
Metadata
List of metadata associated with the answer to be updated
| Name | Type | Description |
|---|---|---|
| add |
List of metadata associated with answer to be added |
|
| delete |
List of Metadata associated with answer to be deleted |
MetadataDTO
Name - value pair of metadata.
| Name | Type | Description |
|---|---|---|
| name |
|
Metadata name. |
| value |
|
Metadata value. |
Operation
Record to track long running operation.
| Name | Type | Description |
|---|---|---|
| createdTimestamp |
|
Timestamp when the operation was created. |
| errorResponse |
Error details in case of failures. |
|
| lastActionTimestamp |
|
Timestamp when the current state was entered. |
| operationId |
|
Operation Id. |
| operationState |
Operation state. |
|
| resourceLocation |
|
Relative URI to the target resource location for completed resources. |
| userId |
|
User Id |
OperationStateType
Operation state.
| Name | Type | Description |
|---|---|---|
| Failed |
|
|
| NotStarted |
|
|
| Running |
|
|
| Succeeded |
|
PromptDTO
Prompt for an answer.
| Name | Type | Description |
|---|---|---|
| displayOrder |
|
Index of the prompt - used in ordering of the prompts |
| displayText |
|
Text displayed to represent a follow up question prompt |
| qna |
QnADTO - Either QnaId or QnADTO needs to be present in a PromptDTO object |
|
| qnaId |
|
Qna id corresponding to the prompt - if QnaId is present, QnADTO object is ignored. |
Qna
QnADTO - Either QnaId or QnADTO needs to be present in a PromptDTO object
QnADTO
Q-A object.
| Name | Type | Description |
|---|---|---|
| answer |
|
Answer text |
| context |
Context of a QnA |
|
| id |
|
Unique id for the Q-A. |
| metadata |
List of metadata associated with the answer. |
|
| questions |
|
List of questions associated with the answer. |
| source |
|
Source from which Q-A was indexed. eg. https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs |
Questions
List of questions associated with the answer.
| Name | Type | Description |
|---|---|---|
| add |
|
List of questions to be added |
| delete |
|
List of questions to be deleted. |
Update
An instance of UpdateKbContentsDTO for Update Operation
| Name | Type | Description |
|---|---|---|
| name |
|
Friendly name for the knowledgebase. |
| qnaList |
List of Q-A (UpdateQnaDTO) to be added to the knowledgebase. |
|
| urls |
|
List of existing URLs to be refreshed. The content will be extracted again and re-indexed. |
UpdateKbOperationDTO
Contains list of QnAs to be updated
| Name | Type | Description |
|---|---|---|
| add |
An instance of CreateKbInputDTO for add operation |
|
| defaultAnswerUsedForExtraction |
|
Text string to be used as the answer in any Q-A which has no extracted answer from the document but has a hierarchy. Required when EnableHierarchicalExtraction field is set to True. |
| delete |
An instance of DeleteKbContentsDTO for delete Operation |
|
| enableHierarchicalExtraction |
|
Enable hierarchical extraction of Q-A from files and urls. The value set during KB creation will be used if this field is not present. |
| update |
An instance of UpdateKbContentsDTO for Update Operation |
UpdateQnaDTO
PATCH Body schema for Update Qna List
| Name | Type | Description |
|---|---|---|
| answer |
|
Answer text |
| context |
Context associated with Qna to be updated. |
|
| id |
|
Unique id for the Q-A |
| metadata |
List of metadata associated with the answer to be updated |
|
| questions |
List of questions associated with the answer. |
|
| source |
|
Source from which Q-A was indexed. eg. https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs |