简体   繁体   中英

Google Assistant - Account linking with Google Sign-In

I have an Express app which supports Google authentication and authorization via passport. I have begun integrating it with Google Assistant and things were going quite well but I am having trouble with the account linking as described at https://developers.google.com/actions/identity/google-sign-in#start_the_authentication_flow

Using the method in the docs at https://codelabs.developers.google.com/codelabs/actions-2/#4 I was able to get user details but when I try to modify to support

app.intent('Start Signin', conv => {
  conv.ask(new SignIn('To get your account details'))
})

and

app.intent('Get Signin', (conv, params, signin) => { ...}

the dialogflow always falls back to my default fallback intent and I get an error in Express console

Error: Dialogflow IntentHandler not found for intent: Default Fallback Intent

My dialogflow intent is set to use webhook and other intents work fine (until I add these sign-in intents!)

Reading this thread Dialogflow IntentHandler not found for intent: myIntent (Dialogflow V2) it was suggested that the intent name rather than the action name is used so I check my Actions on Google simulator and the request contains:

  "inputs": [
    {
      "intent": "actions.intent.SIGN_IN",
      "rawInputs": [
        {
          "inputType": "KEYBOARD"
        }
      ],
      "arguments": [
        {
          "name": "SIGN_IN",
          "extension": {
            "@type": "type.googleapis.com/google.actions.v2.SignInValue",
            "status": "OK"
          }
        }
      ]
    }
  ],

so I tried updating my Dialogflow intent name to actions.intent.SIGN_IN and modifying the intent name in my Express app accordingly but it doesn't make any difference.

The simulator response includes:

"responseMetadata": {
    "status": {
      "code": 14,
      "message": "Webhook error (206)"
    },

but I'm not sure if that is just because for some reason the intent names are not matching up. Any help much appreciated!

在此处输入图片说明

As you speculate in the comments, the issue is that your "Get Signin" Intent isn't registered to get the event indicating that the user has signed in (or failed to). Since there is no such Intent setup, it ends up calling the Fallback Intent, which apparently doesn't have an Intent Handler registered in your webhook.

To make your "Get Signin" Intent get the sign-in event, set the "Event" field to actions_intent_SIGN_IN . (Note the similarity to the Intent name you saw in the simulator, but using underscores instead of dots.)

As an aside, the simulator was showing you what the communication between the Assistant and Dialogflow looks like, so it can be somewhat confusing to understand what Dialogflow is doing with it. It didn't have anything to do with the name of your Intent or anything else.

Finally, it often isn't necessary to do this check. You will know if the user is signed in because either the auth token has been set or the id token has been set (depending on your method of Account Linking).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM