當通過Facebook訪問Lex時,Lex會將Facebook數據傳遞給event.requestAttributes
內的Lambda函數。這是如下結構:
"requestAttributes": {
"x-amz-lex:facebook-page-id": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"x-amz-lex:channel-id": "XXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"x-amz-lex:webhook-endpoint-url": "https://channels.lex.us-east-1.amazonaws.com/facebook/webhook/XXX-XXXX-XXXXXXXXX",
"x-amz-lex:accept-content-types": "PlainText",
"x-amz-lex:user-id": "XXXXXXXXXXXXXXX",
"x-amz-lex:channel-name": "FacebookLexBotAppName",
"x-amz-lex:channel-type": "Facebook"
},
爲了得到頁訪問令牌 = event.requestAttributes['x-amz-lex:facebook-page-id']
爲了得到PSID(頁作用域ID) = event.requestAttributes['x-amz-lex:user-id']