2
votes

I want to enable account linking on an Google Assistant application using Actions Sdk. I have already provided the information in the Account Linking section of the AoG Console : The grant Type is Authorization code. I use Auth0 as Oauth Server and i checked that the endpoints are functional.

When the application is invoked using the simulator, the server application send the following json response :

{
  "expectUserResponse": true,
  "finalResponse": null,
  "expectedInputs": [{
    "possibleIntents": [{
      "intent": "actions.intent.SIGN_IN",
      "inputValueData": null
    }],
    "inputPrompt": {
      "richInitialPrompt": {
        "items": [{
          "simpleResponse": {
            "textToSpeech": "Merci de vous authentifier",
            "ssml": null,
            "displayText": "Merci de vous authentifier"
          }
        }]
      }
    }
  }], 
  "conversationToken": null, 
  "isInSandbox": false
}

I expected then to see the message like : it looks like your account … is not linked

Instead of that, the assistant immediately sends the following request to the server :

{
  "user": {
    "userId": "ABwppHGK6fClByrbLlS8WDM4xfY0qEck5i_kOGMhlJtuj64SjC-8qDqlH3xZ3BN7f9Yz1JDza-sc",
    "locale": "fr-CA",
    "lastSeen": "2018-04-23T14:12:02Z"
  },
  "conversation": {"conversationId": "1524493058716", "type": "NEW"},
  "inputs": [{
    "intent": "actions.intent.SIGN_IN",
    "rawInputs": [{"inputType": "KEYBOARD"}],
    "arguments": [{
      "name": "SIGN_IN",
      "extension": {
        "@type": "type.googleapis.com/google.actions.v2.SignInValue",
        "status": "ERROR"
      }
    }]
  }],
  "surface": {
    "capabilities": [
      {"name": "actions.capability.WEB_BROWSER"}, 
      {"name": "actions.capability.MEDIA_RESPONSE_AUDIO"}, 
      {"name": "actions.capability.SCREEN_OUTPUT"}, 
      {"name": "actions.capability.AUDIO_OUTPUT"}
    ]
  },
  "isInSandbox": true,
  "availableSurfaces": [
    {
      "capabilities": [
        {"name": "actions.capability.SCREEN_OUTPUT"}, 
        {"name": "actions.capability.AUDIO_OUTPUT"}
      ]
    }
  ]
}

Did someone have the same problem ? Thanks

1
How did you request the sign-in ? With the checkbox in the Integrations tab of dialogflow or with Actions SDK? I have a working example with actions SDK and OAuth but I don't have your problem, if it interests you I can post my exampleRémi C.
Hi ! I request the sign-in with actions SDK. Yes, i would be interested with your working example. Thanks in advanceArnaud

1 Answers

0
votes

I have a working example, but it might be different of what you are doing because I ask the sign-in with dialogflow Integrations' tab for Google Assistant, and not explicitely with the SDK. The code is for the V2 of Dialogflow, I also have one for the V1 but it is now legacy.

This is my BONJOUR intent that is triggered when my app is launched:

const rp = require('request-promise');

app.intent('BONJOUR', (conv) => {
    console.log("Debug: SAY_HELLO");
    const accessToken = conv.user.access.token;
    console.log("Access Token = "+accessToken);
    //========Auth with OAuth website========
    if (!accessToken) {
        conv.ask(new SignIn());
    } else {
        let options = {
            method: 'GET',
            url: '[...]',//Oauth URL
            headers:{
                authorization: 'Bearer ' + accessToken,
            }
        };
        // I use the RP lib as we need Promises for the V2 of Dialogflow.
        return rp(options).then((body) => {
            let data = JSON.parse(body);
            console.log("auth data ="+JSON.stringify(data));
            //You can access the auth data easily here
            // For example if you want the name, it's in data.given_name, etc...
            //Use conv.ask() to say something here
        }).catch((error) => {
            console.log("Error in auth request"+error);
        })
    }
});

Update:

This is my JSON mais the SignIn() is called, as I just tested it, it doesn't work (I created an intent that receives the actions_intent_SIGN_IN event from an example. And it never asks for sign In , I'm always in the else.)

Response {
  "payload": {
    "google": {
      "expectUserResponse": true,
      "richResponse": {
        "items": [
          {
            "simpleResponse": {
              "textToSpeech": "PLACEHOLDER"
            }
          }
        ]
      },
      "userStorage": "{\"data\":{}}",
      "systemIntent": {
        "intent": "actions.intent.SIGN_IN",
        "data": {
          "@type": "type.googleapis.com/google.actions.v2.SignInValueSpec"
        }
      }
    }
  },
  "outputContexts": [
    {
      "name": [...],
      "lifespanCount": 99,
      "parameters": {
        "data": "{}"
      }
    }
  ]
}

Then the request after that is:

Request {
  "responseId": "5a711f0e-be66-4311-b776-2085e81e9bde",
  "queryResult": {
    "queryText": "actions_intent_SIGN_IN",
    "parameters": {},
    "allRequiredParamsPresent": true,
    "fulfillmentMessages": [
      {
        "text": {
          "text": [
            ""
          ]
        }
      }
    ],
    "outputContexts": [
      {
        "name": "..."
      },
      {
        "name": ".../actions_intent_sign_in",
        "parameters": {
          "SIGN_IN": {
            "@type": "type.googleapis.com/google.actions.v2.SignInValue",
            "status": "ERROR"
          }
        }
      },
      {
        "name": "...",
        "lifespanCount": 98,
        "parameters": {
          "data": "{}"
        }
      },
      {
        "name": "..."
      },
      {
        "name": "..."
      },
      {
        "name": "..."
      },
      {
        "name": "..."
      }
    ],
    "intent": {
      "name": "...",
      "displayName": "Get Signin"
    },
    "intentDetectionConfidence": 1,
    "diagnosticInfo": {},
    "languageCode": "fr-fr"
  },
  "originalDetectIntentRequest": {
    "source": "google",
    "version": "2",
    "payload": {
      "isInSandbox": true,
      "surface": {
        "capabilities": [
          {
            "name": "actions.capability.WEB_BROWSER"
          },
          {
            "name": "actions.capability.MEDIA_RESPONSE_AUDIO"
          },
          {
            "name": "actions.capability.SCREEN_OUTPUT"
          },
          {
            "name": "actions.capability.AUDIO_OUTPUT"
          }
        ]
      },
      "inputs": [
        {
          "rawInputs": [
            {
              "inputType": "KEYBOARD"
            }
          ],
          "arguments": [
            {
              "extension": {
                "@type": "type.googleapis.com/google.actions.v2.SignInValue",
                "status": "ERROR"
              },
              "name": "SIGN_IN"
            }
          ],
          "intent": "actions.intent.SIGN_IN"
        }
      ],
      "user": {
        "userStorage": "{\"data\":{}}",
        "lastSeen": "2018-04-24T12:21:19Z",
        "locale": "fr-FR",
        "userId": "ABwppHHXrOc7N24RC5YS1dMvt7C-MbpzTb5TtzmufeIpGTCINVlReIMb8RKo4SGQMgBY7BUvO1qhn0B-"
      },
      "conversation": {
        "conversationId": "1524572717282",
        "type": "ACTIVE",
        "conversationToken": "[\"_actions_on_google\"]"
      },
      "availableSurfaces": [
        {
          "capabilities": [
            {
              "name": "actions.capability.SCREEN_OUTPUT"
            },
            {
              "name": "actions.capability.AUDIO_OUTPUT"
            }
          ]
        }
      ]
    }
  },
  "session": "..."
}

I hope it can help you somehow.