How to Implement Persistent Chat in Amazon Connect Flows Using "Create Persistent Contact Association" Block and track chat logs

0

0 Hello AWS Community,

I’m working on enabling persistent chat in Amazon Connect to allow customers to resume previous chat sessions with full conversation history. I’ve followed the AWS documentation here: https://docs.aws.amazon.com/connect/latest/adminguide/chat-persistence.html , but I need clarification on some implementation details.

What I’ve Done:

Created a new contact flow in Amazon Connect and added the "Create persistent contact association" block after the chat contact is initiated. Configured the block to use a user-defined attribute for the source contact ID, which I’m attempting to retrieve from system Initial Contact id. Selected the ENTIRE_PAST_SESSION rehydration mode to resume the full chat history. Challenges/Questions:

How do I correctly retrieve and pass the source contact ID to the "Create persistent contact association" block? Should I use a Lambda function or another block like "Get customer data"? Is there a way to test the persistent chat functionality to confirm that transcripts and context are rehydrated correctly? Are there specific S3 bucket permissions or configurations I need to ensure transcripts are accessible for persistent chat? Can you share any best practices or example flows for implementing persistent chat? Additional Details:

My Amazon Connect instance is configured for chat and voice, and I’m using an inbound chat flow. I’m not using the StartChatContact API; I’m relying solely on the flow-based method. I’m working on an Amazon Connect setup where customers initiate chats through a Communications Widget embedded on our website, and I need help tracking event logs from when the customer starts the chat to when it lands on and progresses through a contact flow. My goal is to monitor events like chat initiation, contact creation, and the execution of flow blocks in real-time or historically, using CloudWatch Logs or other tools. I’ve reviewed the AWS documentation on Amazon Connect flow logs and contact events, but I’m unclear on the exact steps to track these events for chat interactions.

I get this error for my flow block of persistant chat in cloudwatch: { "Results": "Invalid Request Exception Was Thrown While Setting Persistent Contact.", "ContactId": "d4b593a3----91b6e8fb3145", "ContactFlowId": "arn:aws:connect:us-east-1:747926693930:instance/84ecefa9----3288d7c8fd04/contact-flow/494539a5----e499efce2f76", "ContactFlowName": "Demo Chat Flow", "ContactFlowModuleType": "CreatePersistentContactAssociation", "Identifier": "b93c5b2e----db61f694194b", "Timestamp": "2025-05-09T07:12:43.869Z", "Parameters": { "RehydrationType": "Entire Past Session", "SourceContactId": "d4b593a3---****-91b6e8fb3145" } } As you can see it is getting SourceContactId same as contactid.

Any guidance, examples, or confirmation of my approach would be greatly appreciated. Thank you in advance for your help!

2 Answers
0

To implement persistent chat in Amazon Connect flows using the "Create Persistent Contact Association" block and track chat logs, follow these steps:

  1. Retrieving and passing the source contact ID:

    • You're correct that the source contact ID should not be the same as the current contact ID. To retrieve the previous contact ID, you'll need to store it somewhere (like DynamoDB) when the chat ends and retrieve it when a new chat starts.
    • Use a "Set contact attributes" block before the "Create persistent contact association" block to set a user-defined attribute with the retrieved source contact ID.
  2. Testing persistent chat functionality:

    • Create a test flow that includes the "Create persistent contact association" block.
    • Initiate a chat, have a conversation, end the chat, then start a new chat with the same customer.
    • Verify that the previous conversation is displayed in the new chat session.
  3. S3 bucket configurations:

    • Ensure your Amazon Connect instance has the necessary permissions to access the S3 bucket where chat transcripts are stored.
    • Configure appropriate bucket policies and encryption settings as per your security requirements.
  4. Best practices:

    • Use the ENTIRE_PAST_SESSION rehydration type to resume the full chat history.
    • Implement error handling in your flow to manage cases where the source contact ID is not found or invalid.
    • Consider using Lambda functions for more complex logic in retrieving and managing source contact IDs.
  5. Tracking chat logs and events:

    • Enable contact flow logs in your Amazon Connect instance settings.
    • Use Amazon CloudWatch to monitor these logs in real-time.
    • Set up CloudWatch Alarms to alert you of any issues or errors in your flows.
    • Consider using Amazon Connect Streams API to capture detailed chat events on your website.
  6. Resolving the error:

    • The error you're seeing is likely because you're using the current contact ID as the source contact ID.
    • Implement a system to store and retrieve previous contact IDs for each customer, possibly using a database like DynamoDB.
    • Use a Lambda function or external data lookup to fetch the correct previous contact ID before the "Create persistent contact association" block.

Remember to thoroughly test your implementation and monitor logs to ensure the persistent chat is working as expected. If issues persist, review your flow logic and data storage/retrieval methods for previous contact IDs.
Sources
Enable customers to resume chat conversations in Amazon Connect - Amazon Connect
Flow block in Amazon Connect: Create persistent contact association - Amazon Connect
PersistentChat - Amazon Connect
The chat/SMS channel in Amazon Connect - Amazon Connect

profile picture
answered 6 days ago
0

Please note that you will need to implement a repository to store and retrieve the previous contact id which is required in the "Use attribute" section of the "Create persistent contact association" flow block. "Invoke AWS Lambda function" block can be implemented to retrieve the previous contact from an external source.

You may also be required to update the value of previous contact in the repository with the value of current contact ID later in the flow for use as previous contact id in future chat session. Similarly, "Invoke AWS Lambda function" block can be implemented to update contact ID value in the repository.

Please select either of below rehydration types :

  1. Please select "ENTIRE_PAST_SESSION" to rehydrate a chat from the most recently terminated past chat contact of the specified past ended chat session. To use this type, provide the initialContactId of the past ended chat session in the sourceContactId field.

  2. Alternatively, select "FROM_SEGMENT" to rehydrate a chat from the past chat contact that is specified in the sourceContactId field.

For reference your can review https://docs.aws.amazon.com/connect/latest/adminguide/chat-persistence.html#enable-persistent-chat-within-contact-flow

profile pictureAWS
answered 4 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions