如何在Google助手上关联帐户时替换默认响应

时间:2019-02-25 14:54:40

标签: dialogflow actions-on-google google-assistant-sdk account-linking

作为配置为使用以下拓扑链接帐户的操作的一部分:

Google-Actions-> Dialogflow-> Webhook

我看到Google Assistant在进行帐户链接流程之前先注入自己的消息,如下所示:

"I need to link your <action-name> to Google. Is that ok?"

链接流由Webhook中的以下内容触发:

 public ActionResponse launchRequestHandler(ActionRequest request) throws Exception {
    ResponseBuilder responseBuilder = getResponseBuilder(request);
    responseBuilder.add(new SignIn());
}

我希望能够用自定义消息替换上述股票消息,但是,当使用我们自己的消息将上下文附加到登录卡时,就像这样:

String speech = "Hi, I see that your account isn't connected. "
                    + "I've sent a link to your Google Assistant app that will get you started and set up in just several simple steps. "
                    + "Don't worry, I'll be here waiting, just call me when you're ready.";

responseBuilder.add(
                    new SignIn()
                        .setContext(speech));

我仍然在结尾处看到默认消息:

    "Hi, I see that your account isn't connected. 
    I've sent a link to your Google Assistant app that will get you started and set up in just several simple steps.  
Don't worry, I'll be here waiting, just call me when you're ready.,
 I need to link your <action-name> to Google.  Is that ok? "

如何用我自己的邮件替换 Google默认邮件?

1 个答案:

答案 0 :(得分:1)

为确保用户获得一致的体验,您不能 替换默认消息。您只能设置上下文,这样可以在通用问题之前为用户提供自定义信息。

上下文是一条附加信息,可能与您的操作更相关。假设它正在连接到您的example.com帐户。您可以将上下文添加为字符串:

app.intent('Login', conv => {
  conv.ask(new SignIn('To provide you with personalized info from example.com'))
})

用户将听到此消息,并附加通用提示:

  

要为您提供来自example.com的个性化信息,我需要将您的示例操作链接到Google。可以吗?

然后,您可以说是或否,然后执行OAuth流程/ Google登录流程。