
A secure endpoint that receives incoming messages the moment a customer sends one through Facebook Messenger. It verifies the request, extracts the customer's identity, and passes it forward for processing.
Checks whether the customer has messaged before by looking up their Facebook ID in the history store. If found, it retrieves the last contact reference to link the new conversation.
A Lambda function orchestrates the incoming-message flow—validating the webhook, checking history, starting a new chat contact in Amazon Connect, and establishing the connection without requiring a dedicated server.
Once the history check is complete, a new chat contact is created in Amazon Connect, optionally rehydrated with the customer's past conversation, and placed into the agent's queue.
Holds the live connection details (contact ID, participant token) for the duration of the conversation. Allows incoming messages to be matched to an open chat session instead of starting a new one.
A separate, longer-lived table retains the customer's most recent contact ID even after the chat ends. This allows future conversations to be reconnected to the customer's prior history.
Amazon Connect streams real-time chat events to SNS, which triggers the appropriate response: forwarding agent messages to Facebook, updating history, or cleaning up when a chat ends.
When an agent replies inside Amazon Connect, this component securely sends that reply back to the customer's Facebook Messenger inbox using the Facebook Graph API in real time.





