Null response for name and email entities

前端 未结 4 1551
名媛妹妹
名媛妹妹 2021-01-06 06:05

I tried inbuilt variable \"user\" methods, $user.name and $user.email in text response of API.AI, to greet user and show email-Id. Is there any inb

相关标签:
4条回答
  • 2021-01-06 06:38

    I am able to make it work after a long time. We have to enable the webhook first and we can see how to enable the webhook in the dialog flow fulfillment docs If we are going to use Google Assistant, then we have to enable the Google Assistant Integration in the integrations first. Then follow the steps mentioned below for the Account Linking in actions on google:-

    1. Go to google cloud console -> APIsand Services -> Credentials -> OAuth 2.0 client IDs -> Web client -> Note the client ID, client secret from there -> Download JSON - from json note down the project id, auth_uri, token_uri -> Authorised Redirect URIs -> White list our app's URL -> in this URL fixed part is https://oauth-redirect.googleusercontent.com/r/ and append the project id in the URL -> Save the changes

    2. Actions on Google -> Account linking setup 1. Grant type = Authorisation code 2. Client info 1. Fill up client id,client secrtet, auth_uri, token_uri 2. Enter the auth uri as https://www.googleapis.com/auth and token_uri as https://www.googleapis.com/token 3. Save and run 4. It will show an error while running on the google assistant, but dont worry 5. Come back to the account linking section in the assistant settings and enter auth_uri as https://accounts.google.com/o/oauth2/auth and token_uri as https://accounts.google.com/o/oauth2/token 6. Put the scopes as https://www.googleapis.com/auth/userinfo.profile and https://www.googleapis.com/auth/userinfo.email and weare good to go. 7. Save the changes.

    3. In the hosting server logs, we can see the access token value and through access token, we can get the details regarding the email address.

    4. Append the access token to this link "https://www.googleapis.com/oauth2/v1/userinfo?access_token=" and we can get the required details in the resulting json page.
    5. accessToken = req.get("originalRequest").get("data").get("user").get("accessToken")
      r = requests.get(link) print("Email Id= " + r.json()["email"]) print("Name= " + r.json()["name"])
    0 讨论(0)
  • 2021-01-06 06:42

    There is no built-in variable 'user'.
    If you want such functionality, then you need to enable account linking. Use the access_token returned and use it to fetch name, email or anything.

    0 讨论(0)
  • 2021-01-06 06:45

    There is no built in parameter user.

    Even if there was such a built-in parameter, it wouldn't expose the email address automatically (and probably not the name, either).

    Since you are using Actions on Google, you can use it to get user information such as the user's name, but this will require using Fulfillment through a webservice. See How to fetch device location using API AI? for more information about this (name and location are two things you can request permission for).

    The email address, however, is not something you can request in this way. To do this, you'll probably have to go through account linking to link it to a Google identity. See How to authenticate user with just a Google account on Actions on Google? for further info as well.

    0 讨论(0)
  • 2021-01-06 06:46

    Since the original question was asked, there are now ways to get this information - with some caveats.

    You can now use Google Sign In for Assistant to get profile information such as their Google ID and Name. If they have permitted their email address in the profile, this is included as well.

    If you are using the actions-on-google library, this will be available in your Intent Handler in conv.user.profile.payload. If that isn't set, you can request it by using the Sign-In Helper to request it.

    If you are using multivocal, you can set User/IsAuthenticated as a requirement and the information will be available in the environment under User/Profile.

    In either case, the user will have to grant you permission to get the information the first time. After that, this information should be available for all subsequent requests.

    0 讨论(0)
提交回复
热议问题