Search code examples
dialogflow-esactions-on-googlegoogle-assistant-sdkaccount-linking

How to replace default response in account linking on Google Assistant


As part of an action configured for account linking with the following topology:

Actions-on-Google->Dialogflow->Webhook,

I'm seeing Google Assistant injecting its own message prior to going through the account linking flow, as follows:

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

The linking flow is triggered by the following in the webhook:

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

I'd like to be able to replace the above stock message with a custom one, however when attaching a context to a sign in card with our own message, like so:

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));

I'm still seeing the default message tacked at the end:

    "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? "

How can I replace the Google default message with my own?


Solution

  • To ensure a consistent experience for users, you cannot replace the default message. You can only set the context, which lets you provide your custom information for the user ahead of the generic question.

    The context is an additional piece of information which may be more relevant to your Action. Let's say it's connecting to your example.com account. You would add the context as a string:

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

    The user would hear this message, with the generic prompt appended:

    To provide you with personalized info from example.com, I need to link your Example Action to Google. Is that ok?

    Then you can say yes or no, and go through the OAuth flow / Google Sign-In flow.