2017-02-13 35 views
0

我正在使用AWS Lambda和Python來響應API.AI的webhook請求。針對Google Home的API.AI - 需要在webhook中啓動帳戶關聯?

我已經創建了一些谷歌的行動與此棧,他們很好地工作。

我想要啓動帳戶鏈接,在谷歌首頁的對話的中間。 Google提供的文檔假定我使用的是Node.js SDK,我不是。

有什麼需要返回在API.AI網絡掛接響應啓動帳戶鏈接?

如果一些如何使用Node.js可以打印出通過網絡掛接返回的響應對象,讓我知道什麼是我的參數lambda函數需要返回,這將回答這個問題。

- UPDATE Google Actions API https://developers.google.com/actions/reference/conversation的這個頁面非常清楚如何通過Google Actions API請求oauth2帳戶信息。

但是,我使用API​​.AI.如何將我的webhook響應格式化爲API.AI,以便將請求的帳戶權限傳遞給Google Actions?

我試圖把「expected_inputs」場在我的網絡掛接應對的根,並在「數據」:{「谷歌」:{...}}場。都沒有工作。

我們與API.AI的經驗,到目前爲止普遍良好。這僅僅是我們所需要的,到目前爲止,我們無法通過我們目前的堆棧獲得的功能「`

+0

你能解釋一下「帳戶鏈接」是什麼意思嗎?您是否有興趣要求用戶獲得他們的名字或位置的許可?或與其他一些API連接? – matthewayne

+0

我對授予我權限的用戶感興趣,以便接收他們用來登錄Google Home的電子郵件地址。這會讓我發送一個摘要電子郵件給用戶。 –

+0

現在,您只能通過Google上的操作獲取位置信息和用戶名:https://developers.google.com/actions/develop/identity/user-info – matthewayne

回答

1

更新: 你的網絡掛接響應需要包括以下形式的JSON對象請求的權限:

{ 
    "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": [...], 
} 

目前唯一可用的權限是NAME,DEVICE_PRECISE_LOCATION和DEVICE_COARSE_LOCATION這是記錄在這裏:https://developers.google.com/actions/reference/webhook-format#response


以前的答案:

您可以在developer reference(轉載如下)中找到JSON佈局,但Node.js client library使這更容易,看起來像您可以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" 
      } 
     } 
     ] 
    } 
    ] 
} 
+0

我同意https://developers.google .com/actions/reference/conversation顯示Google Actions的API。但是,我想知道如何將這些數據放入我的webhook API.AI中,以便將數據傳遞給Google Action。 –