0

I'm using AWS Lambda and Python to respond to API.AI's webhook requests.

I've created several Google Actions with this stack, and they work fine.

I want to initiate account linking, in the middle of a conversation on Google Home. The documentation provided by Google assumes I'm using the Node.js SDK, which I'm not.

What needs to be returned in the API.AI webhook response to initiate account linking?

If some using Node.js could print out the response object returned by their webhook, so that I know what parameters my Lambda function needs to return, that would answer this question.

-- UPDATE This page of the Google Actions API https://developers.google.com/actions/reference/conversation makes it very clear how to request oauth2 account information through the Google Actions API.

However, I'm using API.AI. How do I format my webhook response to API.AI so that the account permissions requested gets passed along to Google Actions?

I've tried putting the "expected_inputs" field in both the root of my webhook response, and in the "data": {"google": {...}} field. Neither worked.

Our experience with API.AI so far has been generally positive. This is the only functionality we've need so far that we couldn't get through our current stack."`

Owen Brown
  • 179
  • 9
  • Can you explain what you mean by "account-linking"? Are you interested in asking the user for permission for their name or location? Or linking with some other API? – mattcarrollcode Feb 14 '17 at 19:23
  • I'm interested in the user granting permission to me to receive the email address that they used to sign into their Google Home. This would let me send a summary email to the user. – Owen Brown Feb 17 '17 at 01:42
  • Right now, you can only get location information and the user's name with Actions on Google: https://developers.google.com/actions/develop/identity/user-info – mattcarrollcode Feb 22 '17 at 19:22

1 Answers1

1

UPDATE: Your webhook response needs to include a JSON object of the following form to request permissions:

{
  "speech": "...",  // ASCII characters only
  "displayText": "...",
  "data": {
    "google": {
      "expect_user_response": true,
      "is_ssml": true,
      "permissions_request": {
        "opt_context": "...",
        "permissions": [
          "NAME",
          "DEVICE_COARSE_LOCATION",
          "DEVICE_PRECISE_LOCATION"
        ]
      }
    }
  },
  "contextOut": [...],
}

The only permissions currently available are NAME, DEVICE_PRECISE_LOCATION, and DEVICE_COARSE_LOCATION. This is documented here: https://developers.google.com/actions/reference/webhook-format#response


Previous answer:

You can find the JSON layout in the developer reference (reproduced below), but the Node.js client library makes this a lot easier and it looks like you can install npm modules on Lambda.

{
  "user": {
    "user_id": "...",
    "profile": {
      "given_name": "John",
      "family_name": "Doe",
      "display_name": "John Doe"
    },
    "access_token": "..."
  },
  "device": {
    "location": {
      "coordinates": {
        "latitude": 123.456,
        "longitude": -123.456
      },
      "formatted_address": "1234 Random Road, Anytown, CA 12345, United States",
      "city": "Anytown",
      "zip_code": "12345"
    }
  },
  "conversation": {
    "conversation_id": "...",
    "type": "ACTIVE",
    "conversation_token": "..."
  },
  "inputs": [
    {
      "intent": "assistant.intent.action.MAIN",
      "raw_inputs": [
        {
          "query": "..."
        }
      ],
      "arguments": [
        {
          "name": "destination",
          "raw_text": "SFO",
          "location_value": {
            "latlng": {
              "latitude": 37.620565,
              "longitude": -122.384964
            },
            "formatted_address": "1000 Broadway, San Francisco, CA 95133"
          }
        }
      ]
    }
  ]
}
mattcarrollcode
  • 3,429
  • 16
  • 16
  • I agree that the https://developers.google.com/actions/reference/conversation shows the API for Google Actions. But, I want to know what to put this data in my webhook to API.AI so that the data gets passed along to Google Action. – Owen Brown Feb 17 '17 at 05:31