Skip to content

Commit 7d76ff1

Browse files
committed
4.0.2: fix #35 feedback form auto-fill (and detect screen)
1 parent 0fa955a commit 7d76ff1

File tree

2 files changed

+9
-18
lines changed

2 files changed

+9
-18
lines changed

index.js

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,20 @@ const v = 4; // also edit the intents "-1.0 No/Bye" and "1.0 Default Welcome Int
1111
// make this the only global variable for the complex parsing
1212
var codeVariables = [];
1313

14-
function hasScreenOutput(request) {
15-
if (request !== undefined) {
16-
let requestPayload = request.body.originalDetectIntentRequest.payload;
17-
if (requestPayload.surface && requestPayload.surface.capabilities && requestPayload.surface.capabilities[0]) {
18-
for (let i=0; i<requestPayload.surface.capabilities.length; i++) {
19-
if (requestPayload.surface.capabilities[i].name == 'actions.capability.SCREEN_OUTPUT') {
20-
return true;
21-
}
22-
}
23-
}
24-
}
25-
return false;
14+
function hasScreenOutput(conv) {
15+
const hasScreen = conv.surface.capabilities.has('actions.capability.SCREEN_OUTPUT');
16+
return hasScreen;
2617
}
2718

2819
app.intent('0.1 Default Fallback Intent - yes - suggestion', function suggestionPrefill(conv) {
2920
let suggestion = conv.contexts.get('suggest').parameters.suggestion;
30-
//let hasScreen = hasScreenOutput(request);
21+
let hasScreen = hasScreenOutput(conv);
3122

32-
//if (hasScreen) {
33-
//conv.ask(`Thanks! Right now, I can't open a link for you hands-free. But here's a link to a feedback form pre-filled for you:`);
34-
//} else {
23+
if (hasScreen) {
24+
conv.ask(`Thanks! Right now, I can't open a link for you hands-free. But here's a link to a feedback form pre-filled for you:`);
25+
} else {
3526
conv.ask(`Sorry! Right now, I can't open a link for you hands-free. If you use a device with a screen, you'll see a button to go to a feedback form.`);
36-
//}
27+
}
3728

3829
conv.ask(new BasicCard({
3930
title: `Send feedback`,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "dialogflowFirebaseFulfillment",
33
"description": "This is Code Tutor's fulfillment using Cloud Functions for Firebase",
4-
"version": "4.0.1",
4+
"version": "4.0.2",
55
"private": true,
66
"license": "Apache Version 2.0",
77
"author": "Howard Chiam (unless someone forked this project)",

0 commit comments

Comments
 (0)