建议筹码显示不一致

时间:2019-03-10 11:52:09

标签: javascript dialogflow actions-on-google

我正在跟踪Codelabs tutorial to build Actions for Google Assistant,但是一些建议筹码没有显示。

我为多个意图实现了建议芯片。按照对话流程的顺序,它首先无法显示Level 2 Step 5的颜色选项,然后成功显示了Level 2 Step 8的是/否筹码,但是再次无法尝试显示{{3 }}。

“失败”-Level 3 Step 9,成功-color options和失败-yes/no的“显示”标签中的屏幕快照(“响应”标签中的JSON文本的摘录也包含在相同顺序)。

我的履行代码中的代码段以相同的顺序显示:

// Handle the Dialogflow intent named 'actions_intent_PERMISSION'. If user
// agreed to PERMISSION prompt, then boolean value 'permissionGranted' is true.

app.intent('actions_intent_PERMISSION', (conv, params, permissionGranted) => {
  if (!permissionGranted) {
    // If the user denied our request, go ahead with the conversation.
    conv.ask(`OK, no worries. What's your favorite color?`);
    conv.ask(new Suggestions('Blue', 'Red', 'Green'));
  } else {
    // If the user accepted our request, store their name in
    // the 'conv.user.storage' object for the duration of the conversation.
    conv.user.storage.userName = conv.user.name.display;
    conv.ask(`Thanks, ${conv.user.storage.userName}. What's your favorite color?`);
    conv.ask(new Suggestions('Blue', 'Red', 'Green'));
  }
});

// Handle the Dialogflow intent named 'favorite color'.
// The intent collects a parameter named 'color'.
app.intent('favorite color', (conv, {
  color
}) => {
  const luckyNumber = color.length;
  const audioSound = 'https://actions.google.com/sounds/v1/cartoon/clang_and_wobble.ogg';
  if (conv.user.storage.userName) {
    // If we collected user name previously, address them by name and use SSML
    // to embed an audio snippet in the response.
    conv.ask(`<speak>${conv.user.storage.userName}, your lucky number is ` +
      `${luckyNumber}.<audio src="${audioSound}"></audio> ` +
      `Would you like to hear some fake colors?</speak>`);
    conv.ask(new Suggestions('Yes', 'No'));
  } else {
    conv.ask(`<speak>Your lucky number is ${luckyNumber}.` +
      `<audio src="${audioSound}"></audio> ` +
      `Would you like to hear some fake colors?</speak>`);
    conv.ask(new Suggestions('Yes', 'No'));
  }
});

// Handle the Dialogflow intent named 'favorite fake color'.
// The intent collects a parameter named 'fakeColor'.
app.intent('favorite fake color', (conv, {
  fakeColor
}) => {
  fakeColor = conv.arguments.get('OPTION') || fakeColor;
  // Present user with the corresponding basic card and end the conversation.
  if (!conv.screen) {
    conv.ask(colorMap[fakeColor].text);
  } else {
    conv.ask(`Here you go.`, new BasicCard(colorMap[fakeColor]));
  }
  conv.ask('Do you want to hear about another fake color?');
  conv.ask(new Suggestions('Yes', 'No'));
});

//failed - color options
{
  "payload": {
    "google": {
      "expectUserResponse": true,
      "richResponse": {
        "items": [
          {
            "simpleResponse": {
              "textToSpeech": "OK, no worries. What's your favorite color?"
            }
          }
        ],
        "suggestions": [
          {
            "title": "Blue"
          },
          {
            "title": "Red"
          },
          {
            "title": "Green"
          }
        ]
      }
    }
  }
}

// successful yes/no
{
  "payload": {
    "google": {
      "expectUserResponse": true,
      "richResponse": {
        "items": [
          {
            "simpleResponse": {
              "textToSpeech": "<speak>Your lucky number is 4.<audio src=\"https://actions.google.com/sounds/v1/cartoon/clang_and_wobble.ogg\"></audio> Would you like to hear some fake colors?</speak>"
            }
          }
        ],
        "suggestions": [
          {
            "title": "Yes"
          },
          {
            "title": "No"
          }
        ]
      }
    }
  }
}

//failed - yes/no
{
  "payload": {
    "google": {
      "expectUserResponse": true,
      "richResponse": {
        "items": [
          {
            "simpleResponse": {
              "textToSpeech": "Here you go."
            }
          },
          {
            "basicCard": {
              "title": "Pink Unicorn",
              "formattedText": "Pink Unicorn is an imaginative reddish hue.",
              "image": {
                "url": "https://storage.googleapis.com/material-design/publish/material_v_12/assets/0BxFyKV4eeNjDbFVfTXpoaEE5Vzg/style-color-uiapplication-palette2.png",
                "accessibilityText": "Pink Unicorn Color"
              },
              "imageDisplayOptions": "WHITE"
            }
          },
          {
            "simpleResponse": {
              "textToSpeech": "Do you want to hear about another fake color?"
            }
          }
        ],
        "suggestions": [
          {
            "title": "Yes"
          },
          {
            "title": "No"
          }
        ]
      }
    }
  }
}

1 个答案:

答案 0 :(得分:1)

这是“ Google模拟器上的操作”存在的问题,建议将在真实设备上运行。