You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/cognitive-services/QnAMaker/How-To/multiturn-conversation.md
+38-36Lines changed: 38 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ ms.custom: seodec18
9
9
ms.service: cognitive-services
10
10
ms.subservice: qna-maker
11
11
ms.topic: conceptual
12
-
ms.date: 09/25/2019
12
+
ms.date: 12/05/2019
13
13
ms.author: diberry
14
14
---
15
15
@@ -25,15 +25,15 @@ To see how multi-turn works, view the following demonstration video:
25
25
26
26
Some questions can't be answered in a single turn. When you design your client application (chat bot) conversations, a user might ask a question that needs to be filtered or refined to determine the correct answer. You make this flow through the questions possible by presenting the user with *follow-up prompts*.
27
27
28
-
When a user asks a question, QnA Maker returns the answer _and_ any follow-up prompts. This response allows you to present the follow-up questions as choices.
28
+
When a user asks a question, QnA Maker returns the answer _and_ any follow-up prompts. This response allows you to present the follow-up questions as choices.
29
29
30
30
## Example multi-turn conversation with chat bot
31
31
32
32
With multi-turn, a chat bot manages a conversation with a user to determine the final answer, as shown in the following image:
33
33
34
34

35
35
36
-
In the preceding image, a user has started a conversation by entering **My account**. The knowledge base has three linked question-and-answer pairs. To refine the answer, the user selects one of the three choices in the knowledge base. The question (#1), has three follow-up prompts, which are presented in the chat bot as three options (#2).
36
+
In the preceding image, a user has started a conversation by entering **My account**. The knowledge base has three linked question-and-answer pairs. To refine the answer, the user selects one of the three choices in the knowledge base. The question (#1), has three follow-up prompts, which are presented in the chat bot as three options (#2).
37
37
38
38
When the user selects an option (#3), the next list of refining options (#4) is presented. This sequence continues (#5) until the user determines the correct, final answer (#6).
39
39
@@ -44,32 +44,34 @@ After publishing your KB, you can select the **Create Bot** button to deploy you
44
44
45
45
## Create a multi-turn conversation from a document's structure
46
46
47
-
When you create a knowledge base, the **Populate your KB** section displays an **Enable multi-turn extraction from URLs, .pdf or .docx files** check box.
47
+
When you create a knowledge base, the **Populate your KB** section displays an **Enable multi-turn extraction from URLs, .pdf or .docx files** check box.
48
48
49
49

50
50
51
-
When you select this option, QnA Maker extracts the hierarchy present in the document structure. The hierarchy is converted in to follow up prompts and the root of the hierarchy serves as the parent QnA. In some documents the root of the hierarchy does not have content which could serve as an answer, you can provide the 'Default Answer Text' to be used as a substitute answer text to extract such hierarchies.
51
+
When you select this option, QnA Maker extracts the hierarchy present in the document structure. The hierarchy is converted in to follow up prompts and the root of the hierarchy serves as the parent QnA. In some documents the root of the hierarchy does not have content which could serve as an answer, you can provide the 'Default Answer Text' to be used as a substitute answer text to extract such hierarchies.
52
52
53
-
Multi-turn structure can be inferred only from URLs, PDF files, or DOCX files. For an example of structure, view an image of a [Microsoft Surface user manual PDF file](https://github.com/Azure-Samples/cognitive-services-sample-data-files/blob/master/qna-maker/data-source-formats/product-manual.pdf).
53
+
Multi-turn structure can be inferred only from URLs, PDF files, or DOCX files. For an example of structure, view an image of a [Microsoft Surface user manual PDF file](https://github.com/Azure-Samples/cognitive-services-sample-data-files/blob/master/qna-maker/data-source-formats/product-manual.pdf).
54
54
55
55
](../media/conversational-context/import-file-with-conversational-structure.png#lightbox)
56
56
57
57
### Building your own multi-turn document
58
58
59
59
If you are creating a multi-turn document, please keep in mind the following guidelines:
60
60
61
-
* Use headings and sub-headings to denote hierarchy. For example You can h1 to denote the parent QnA and h2 to denote the QnA that should be taken as prompt. Use small heading size to denote subsequent hierarchy. Don't use style, color, or some other mechanism to imply structure in your document, QnA Maker will not extract the multi-turn prompts.
61
+
* Use headings and sub-headings to denote hierarchy. For example You can h1 to denote the parent QnA and h2 to denote the QnA that should be taken as prompt. Use small heading size to denote subsequent hierarchy. Don't use style, color, or some other mechanism to imply structure in your document, QnA Maker will not extract the multi-turn prompts.
62
62
63
-
* Do not end a heading with a question mark, `?`.
63
+
* First character of heading must be capitalized.
64
+
65
+
* Do not end a heading with a question mark, `?`.
64
66
65
67
* You can use the [sample document](https://github.com/Azure-Samples/cognitive-services-sample-data-files/blob/master/qna-maker/data-source-formats/multi-turn.docx) as an example to create your own multi-turn document.
66
68
67
69
### Adding files to a multi-turn KB
68
70
69
-
When you add a hierarchical document, QnA Maker determines follow-up prompts from the structure to create conversational flow.
71
+
When you add a hierarchical document, QnA Maker determines follow-up prompts from the structure to create conversational flow.
70
72
71
-
1. In QnA Maker, select an existing knowledge base which was created with **Enable multi-turn extraction from URLs, .pdf or .docx files.** enabled.
72
-
1. Go to the **Settings** page, select the file or URL to add.
73
+
1. In QnA Maker, select an existing knowledge base which was created with **Enable multi-turn extraction from URLs, .pdf or .docx files.** enabled.
74
+
1. Go to the **Settings** page, select the file or URL to add.
73
75
1.**Save and train** the knowledge base.
74
76
75
77
> [!Caution]
@@ -78,25 +80,25 @@ When you add a hierarchical document, QnA Maker determines follow-up prompts fro
78
80
79
81
## Create knowledge base with multi-turn prompts with the Create API
80
82
81
-
You can create a knowledge case with multi-turn prompts using the [QnA Maker Create API](https://docs.microsoft.com/rest/api/cognitiveservices/qnamaker/knowledgebase/create). The prompts are adding in the `context` property's `prompts` array.
83
+
You can create a knowledge case with multi-turn prompts using the [QnA Maker Create API](https://docs.microsoft.com/rest/api/cognitiveservices/qnamaker/knowledgebase/create). The prompts are adding in the `context` property's `prompts` array.
82
84
83
85
## Show questions and answers with context
84
86
85
-
Reduce the displayed question-and-answer pairs to only those with contextual conversations.
87
+
Reduce the displayed question-and-answer pairs to only those with contextual conversations.
86
88
87
-
Select **View options**, and then select **Show context**. The list displays question-and-answer pairs that contain follow-up prompts.
89
+
Select **View options**, and then select **Show context**. The list displays question-and-answer pairs that contain follow-up prompts.
88
90
89
91

90
92
91
93
The multi-turn context is displayed in the first column.
In the preceding image, **#1** indicates bold text in the column, which signifies the current question. The parent question is the top item in the row. Any questions below it are the linked question-and-answer pairs. These items are selectable, so that you can immediately go to the other context items.
97
+
In the preceding image, **#1** indicates bold text in the column, which signifies the current question. The parent question is the top item in the row. Any questions below it are the linked question-and-answer pairs. These items are selectable, so that you can immediately go to the other context items.
96
98
97
99
## Add an existing question-and-answer pair as a follow-up prompt
98
100
99
-
The original question, **My account**, has follow-up prompts, such as **Accounts and signing in**.
101
+
The original question, **My account**, has follow-up prompts, such as **Accounts and signing in**.
100
102
101
103

102
104
@@ -113,35 +115,35 @@ Add a follow-up prompt to an existing question-and-answer pair that isn't curren
113
115
|Link to answer|Enter **Use the sign-in screen** to find the existing question-and-answer pair.|
114
116
115
117
116
-
1. One match is returned. Select this answer as the follow-up, and then select **Save**.
118
+
1. One match is returned. Select this answer as the follow-up, and then select **Save**.
1. After you've added the follow-up prompt, select **Save and train** in the top navigation.
121
-
122
-
### Edit the display text
123
123
124
-
When a follow-up prompt is created, and an existing question-and-answer pair is entered as the **Link to Answer**, you can enter new **Display text**. This text doesn't replace the existing question, and it doesn't add a new alternate question. It is separate from those values.
124
+
### Edit the display text
125
+
126
+
When a follow-up prompt is created, and an existing question-and-answer pair is entered as the **Link to Answer**, you can enter new **Display text**. This text doesn't replace the existing question, and it doesn't add a new alternate question. It is separate from those values.
125
127
126
128
1. To edit the display text, search for and select the question in the **Context** field.
127
-
1. In the row for that question, select the follow-up prompt in the answer column.
129
+
1. In the row for that question, select the follow-up prompt in the answer column.
128
130
1. Select the display text you want to edit, and then select **Edit**.
129
131
130
132

131
133
132
-
1. In the **Follow-up prompt** pop-up window, change the existing display text.
133
-
1. When you're done editing the display text, select **Save**.
134
+
1. In the **Follow-up prompt** pop-up window, change the existing display text.
135
+
1. When you're done editing the display text, select **Save**.
134
136
1. In the top navigation bar, **Save and train**.
135
137
136
138
137
139
## Add a new question-and-answer pair as a follow-up prompt
138
140
139
141
When you add a new question-and-answer pair to the knowledge base, each pair should be linked to an existing question as a follow-up prompt.
140
142
141
-
1. On the knowledge base toolbar, search for and select the existing question-and-answer pair for **Accounts and signing in**.
143
+
1. On the knowledge base toolbar, search for and select the existing question-and-answer pair for **Accounts and signing in**.
142
144
143
-
1. In the **Answer** column for this question, select **Add follow-up prompt**.
144
-
1. Under **Follow-up prompt (PREVIEW)**, create a new follow-up prompt by entering the following values:
145
+
1. In the **Answer** column for this question, select **Add follow-up prompt**.
146
+
1. Under **Follow-up prompt (PREVIEW)**, create a new follow-up prompt by entering the following values:
145
147
146
148
|Field|Value|
147
149
|--|--|
@@ -153,9 +155,9 @@ When you add a new question-and-answer pair to the knowledge base, each pair sho
153
155

154
156
155
157
156
-
1. Select **Create new**, and then select **Save**.
158
+
1. Select **Create new**, and then select **Save**.
157
159
158
-
This action creates a new question-and-answer pair and links the selected question as a follow-up prompt. The **Context** column, for both questions, indicates a follow-up prompt relationship.
160
+
This action creates a new question-and-answer pair and links the selected question as a follow-up prompt. The **Context** column, for both questions, indicates a follow-up prompt relationship.
159
161
160
162
1. Select **View options**, and then select [**Show context (PREVIEW)**](#show-questions-and-answers-with-context).
161
163
@@ -179,7 +181,7 @@ If you don't enable multi-turn, the answer is returned but follow-up prompts are
179
181
180
182
## A JSON request to return an initial answer and follow-up prompts
181
183
182
-
Use the empty `context` object to request the answer to the user's question and include follow-up prompts.
184
+
Use the empty `context` object to request the answer to the user's question and include follow-up prompts.
183
185
184
186
```JSON
185
187
{
@@ -193,7 +195,7 @@ Use the empty `context` object to request the answer to the user's question and
193
195
194
196
## A JSON response to return an initial answer and follow-up prompts
195
197
196
-
The preceding section requested an answer and any follow-up prompts to **Accounts and signing in**. The response includes the prompt information, which is located at *answers[0].context*, and the text to display to the user.
198
+
The preceding section requested an answer and any follow-up prompts to **Accounts and signing in**. The response includes the prompt information, which is located at *answers[0].context*, and the text to display to the user.
197
199
198
200
```JSON
199
201
{
@@ -258,7 +260,7 @@ The preceding section requested an answer and any follow-up prompts to **Account
258
260
}
259
261
```
260
262
261
-
The `prompts` array provides text in the `displayText` property and the `qnaId` value. You can show these answers as the next displayed choices in the conversation flow and then send the selected `qnaId` back to QnA Maker in the following request.
263
+
The `prompts` array provides text in the `displayText` property and the `qnaId` value. You can show these answers as the next displayed choices in the conversation flow and then send the selected `qnaId` back to QnA Maker in the following request.
262
264
263
265
<!--
264
266
@@ -270,7 +272,7 @@ The `promptsToDelete` array provides the ...
270
272
271
273
Fill the `context` object to include the previous context.
272
274
273
-
In the following JSON request, the current question is *Use Windows Hello to sign in* and the previous question was *accounts and signing in*.
275
+
In the following JSON request, the current question is *Use Windows Hello to sign in* and the previous question was *accounts and signing in*.
274
276
275
277
```JSON
276
278
{
@@ -284,7 +286,7 @@ In the following JSON request, the current question is *Use Windows Hello to sig
284
286
"previousUserQuery": "accounts and signing in"
285
287
}
286
288
}
287
-
```
289
+
```
288
290
289
291
## A JSON response to return a non-initial answer and follow-up prompts
290
292
@@ -348,16 +350,16 @@ The QnA Maker _GenerateAnswer_ JSON response includes the follow-up prompts in t
348
350
349
351
## Query the knowledge base with the QnA Maker ID
350
352
351
-
If you are building a custom application using multi-turn feature. In the initial question's response, any follow-up prompts and its associated `qnaId` is returned. Now that you have the ID, you can pass this in the follow-up prompt's request body. If the request body contains the `qnaId`, and the context object (which contains the previous QnA Maker properties), then GenerateAnswer will return the exact question by ID, instead of using the ranking algorithm to find the answer by the question text.
353
+
If you are building a custom application using multi-turn feature. In the initial question's response, any follow-up prompts and its associated `qnaId` is returned. Now that you have the ID, you can pass this in the follow-up prompt's request body. If the request body contains the `qnaId`, and the context object (which contains the previous QnA Maker properties), then GenerateAnswer will return the exact question by ID, instead of using the ranking algorithm to find the answer by the question text.
352
354
353
355
354
356
## Display order is supported in the Update API
355
357
356
-
The [display text and display order](https://docs.microsoft.com/rest/api/cognitiveservices/qnamaker/knowledgebase/update#promptdto), returned in the JSON response, is supported for editing by the [Update API](https://docs.microsoft.com/rest/api/cognitiveservices/qnamaker/knowledgebase/update).
358
+
The [display text and display order](https://docs.microsoft.com/rest/api/cognitiveservices/qnamaker/knowledgebase/update#promptdto), returned in the JSON response, is supported for editing by the [Update API](https://docs.microsoft.com/rest/api/cognitiveservices/qnamaker/knowledgebase/update).
357
359
358
360
## Add or delete multi-turn prompts with the Update API
359
361
360
-
You can add or delete multi-turn prompts using the [QnA Maker Update API](https://docs.microsoft.com/rest/api/cognitiveservices/qnamaker/knowledgebase/update). The prompts are adding in the `context` property's `promptsToAdd` array and the `promptsToDelete` array.
362
+
You can add or delete multi-turn prompts using the [QnA Maker Update API](https://docs.microsoft.com/rest/api/cognitiveservices/qnamaker/knowledgebase/update). The prompts are adding in the `context` property's `promptsToAdd` array and the `promptsToDelete` array.
0 commit comments