Reputation: 165
I'm currently doing some proof of concept stuff with Amazon Lex, Lambda, and the Facebook Messenger Webhook integration for chatbots.
I see through Facebook's Webhook that when messages are sent to Lex, they include a user ID (which I believe is the Page Scoped ID).
Through Lambda initialization and validation with Amazon Lex, I don't see this page scoped ID passed anywhere in the event object inside of Lambda, which leads me to believe Lex if formatting the event and stripping out any body content that is passed from Facebook.
Is there a way to read the body content of the incoming request?
Upvotes: 0
Views: 624
Reputation: 3287
When accessing Lex through Facebook, Lex will pass Facebook data to your Lambda Function inside of event.requestAttributes
. This is the structure:
"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"
},
To get the Page Access Token = event.requestAttributes['x-amz-lex:facebook-page-id']
To get the PSID (Page Scoped ID) = event.requestAttributes['x-amz-lex:user-id']
Upvotes: 1