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/nodejs/bot-builder-nodejs-cortana-skill.md
+18-11Lines changed: 18 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ manager: kamrani
6
6
ms.topic: article
7
7
ms.service: bot-service
8
8
ms.subservice: sdk
9
-
ms.date: 12/13/2017
9
+
ms.date: 02/10/2019
10
10
monikerRange: 'azure-bot-service-3.0'
11
11
---
12
12
# Build a speech-enabled bot with Cortana skills
@@ -53,42 +53,46 @@ The **inputHint** property helps indicate to Cortana whether your bot is expecti
53
53
|------|------|
54
54
|**acceptingInput**| Your bot is passively ready for input but is not waiting on a response. Cortana accepts input from the user if the user holds down the microphone button.|
55
55
|**expectingInput**| Indicates that the bot is actively expecting a response from the user. Cortana listens for the user to speak into the microphone. |
56
-
|**ignoringInput**| Cortana is ignoring input. Your bot may send this hint if it is actively processing a request and will ignore input from users until the request is complete. |
57
-
56
+
||NOTE: Do _not_ use **expectingInput**on headless devices (devices without a display). See the [Cortana Skills Kit FAQ](https://review.docs.microsoft.com/en-us/cortana/skills/faq).|
57
+
|**ignoringInput**| Cortana is ignoring input. Your bot may send this hint if it is actively processing a request, and will ignore input from users until the request is complete. |
58
58
59
59
The following example shows how Cortana reads plain text or SSML:
60
60
61
61
```javascript
62
+
62
63
// Have Cortana read plain text
63
64
session.say('This is the text that Cortana displays', 'This is the text that is spoken by Cortana.');
64
65
65
66
// Have Cortana read SSML
66
67
session.say('This is the text that Cortana displays', '<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xml:lang="en-US">This is the text that is spoken by Cortana.</speak>');
68
+
67
69
```
68
70
69
71
This example shows how to let Cortana know that user input is expected. The microphone will be left open.
72
+
70
73
```javascript
74
+
71
75
// Add an InputHint to let Cortana know to expect user input
72
76
session.say('Hi there', 'Hi, what’s your name?', {
73
77
inputHint:builder.InputHint.expectingInput
74
78
});
79
+
75
80
```
76
81
<!-- TODO: tip about time limit and batching -->
77
82
78
-
79
83
### Prompts
80
84
81
85
In addition to using the **session.say()** method you can also pass text or SSML to built-in prompts using the **speak** and **retrySpeak** options.
82
86
83
87
```javascript
88
+
84
89
builder.Prompts.text(session, 'text based prompt', {
85
90
speak:'Cortana reads this out initially',
86
91
retrySpeak:'This message is repeated by Cortana after waiting a while for user input',
87
92
inputHint:builder.InputHint.expectingInput
88
93
});
89
-
```
90
-
91
94
95
+
```
92
96
93
97
<!-- TODO: Link to SSML library -->
94
98
@@ -97,6 +101,7 @@ To present the user with a list of choices, use **Prompts.choice**. The **synony
97
101
**Prompts.choice** supports ordinal choices. This means that the user can say "the first", "the second" or "the third" to choose an item in a list. For example, given the following prompt, if the user asked Cortana for "the second option", the prompt will return the value of 8.
speak:speak(session, 'choose_sides_ssml') // use helper function to format SSML
108
113
});
114
+
109
115
```
110
116
111
117
In the previous example, the SSML for the prompt's **speak** property is formatted by using strings stored in a localized prompts file with the following format.
112
118
113
119
```json
120
+
114
121
{
115
122
"choose_sides": "__Number of Sides__",
116
123
"choose_sides_ssml": [
@@ -119,8 +126,8 @@ In the previous example, the SSML for the prompt's **speak** property is formatt
119
126
"All the standard sizes are supported."
120
127
]
121
128
}
122
-
```
123
129
130
+
```
124
131
125
132
A helper function then builds the required root element of a Speech Synthesis Markup Language (SSML) document.
126
133
@@ -152,7 +159,7 @@ See [Card design best practices][CardDesign] to see what these cards look like i
152
159
153
160
The following code demonstrates how to add the **speak** and **inputHint** properties to a message containing a Hero card.
154
161
155
-
```javascript
162
+
```javascript
156
163
157
164
bot.dialog('HelpDialog', function (session) {
158
165
var card =newbuilder.HeroCard(session)
@@ -168,7 +175,6 @@ bot.dialog('HelpDialog', function (session) {
168
175
session.send(msg).endDialog();
169
176
}).triggerAction({ matches:/help/i });
170
177
171
-
172
178
/** This helper function builds the required root element of a Speech Synthesis Markup Language (SSML) document. */
0 commit comments