Skip to content

Commit

Permalink
4.0.2: fix #35 feedback form auto-fill (and detect screen)
Browse files Browse the repository at this point in the history
  • Loading branch information
hchiam committed Oct 15, 2019
1 parent 0fa955a commit 7d76ff1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
25 changes: 8 additions & 17 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,20 @@ const v = 4; // also edit the intents "-1.0 No/Bye" and "1.0 Default Welcome Int
// make this the only global variable for the complex parsing
var codeVariables = [];

function hasScreenOutput(request) {
if (request !== undefined) {
let requestPayload = request.body.originalDetectIntentRequest.payload;
if (requestPayload.surface && requestPayload.surface.capabilities && requestPayload.surface.capabilities[0]) {
for (let i=0; i<requestPayload.surface.capabilities.length; i++) {
if (requestPayload.surface.capabilities[i].name == 'actions.capability.SCREEN_OUTPUT') {
return true;
}
}
}
}
return false;
function hasScreenOutput(conv) {
const hasScreen = conv.surface.capabilities.has('actions.capability.SCREEN_OUTPUT');
return hasScreen;
}

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

//if (hasScreen) {
//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:`);
//} else {
if (hasScreen) {
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:`);
} else {
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.`);
//}
}

conv.ask(new BasicCard({
title: `Send feedback`,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "dialogflowFirebaseFulfillment",
"description": "This is Code Tutor's fulfillment using Cloud Functions for Firebase",
"version": "4.0.1",
"version": "4.0.2",
"private": true,
"license": "Apache Version 2.0",
"author": "Howard Chiam (unless someone forked this project)",
Expand Down

0 comments on commit 7d76ff1

Please sign in to comment.