Enable persistent chat - Amazon Connect

Enable persistent chat

Customers often start a chat, then leave the conversation and return later to continue chatting. This may happen many times over the course of several days, months, or even years. To support long running chats like these, you enable persistent chat.

With persistent chat, customers can resume previous conversations with the context, metadata, and transcripts carried forward. Customers don't need to repeat themselves when they return to a chat, and agents have access to the entire conversation history.

Chat rehydration

Persistent chat is achieved through a process called chat rehydration, this process enables chat transcripts to be retrieved from previous chat contacts and displayed, allowing customers and agents to easily continue conversations from where they left off.

Important

Only chat sessions that have ended are allowed to rehydrate onto a new chat session.

Amazon Connect supports two types of rehydration:

  • ENTIRE_PAST_SESSION: Starts a new chat session and rehydrates all chat segments from past chat sessions.

  • FROM_SEGMENT: Starts a new session and rehydrates from the specified past chat segment.

For example use cases that show these different rehydration modes, see Example use cases.

RelatedContactId

A new contact can have an association with an existing contact through the RelatedContactId. This new contact contains a copy of the contact properties from the related contact.

For more information about how the RelatedContactId is modeled in contact records, see Contact records data model.

For persistent chat, the RelatedContactId depicts the contactId used to source chat rehydration.

How to enable persistent chat

To enable persistent chat, you can either specify a previous contact ID when creating a new chat or you can add the Create persistent contact association block to a contact flow.

Note

You can choose either method, noted below, to persist chats but not both. That is, you can only enable persistence of a SourceContactID on a new chat once.

To deliver persistent chat experiences you need to provide a previous contact ID when starting a new chat or when using the Create persistent contact association flow block. This is not automatically done for you. It is recommended that you create a repository for storing CTR data, which will enable retrieval of this data for each of your customers. This can be done using chat message streaming to create an entry when a chat has ended or alternatively by inspecting Contact events and using AWS Lambda function for creating entries into your repository. After a repository is setup you can retrieve the previous contact ID for the customer and provide it when starting a new chat or within the Create persistent contact association flow block.

In addition, please ensure past chat transcripts can be retrieved from your instance's Amazon S3 bucket. Using multiple chat transcript buckets or changing the chat transcript file name that is generated by Amazon Connect will prevent retrieval of transcripts, and will not allow chats to persist.

Enable Persistent chat when creating a new chat contact

To set up persistent chat experiences when creating a new chat contact, provide the previous contactId in the SourceContactId parameter of the StartChatContact API, this will enable the chat transcripts of previous contacts to be “rehydrated” and shown to both the customer and agent within the chat UI’s, see Example use cases.

Enable Persistent chat within a contact flow

To setup persistent chat experiences within a contact flow, after a chat contact has been created, add the Create persistent contact association block to your contact flow and programmatically specify a source contact ID by using a user defined attribute. You can also use the new CreatePersistentContactAssociation API and provide a source contact ID to make the current chat persistent. For more information, see CreatePersistentContactAssociation in the Amazon Connect API Reference.


                    Creating a persistent contact in contact flow.

Example use cases

For example, a customer starts a chat session:

  1. Agent a1 accepts the chat, and the conversation starts between the customer and agent a1. This is the first contact created in the current chat session. For example, the contactId C1 might be 11111111-aaaa-bbbb-1111-1111111111111.

  2. Agent a1 then transfers the chat to Agent a2. This creates another contact. For example, contactId C2 might be 2222222-aaaa-bbbb-2222-222222222222222.

  3. Agent a2 ends the chat.

  4. The customer is forwarded to the disconnect flow for a post-chat survey that creates another contact. For example, contactId C3 might be 33333333-aaaa-bbbb-3333-3333333333333.

  5. The post-chat survey is displayed, and the chat session ends.

  6. Later, the customer returns and wants to resume their past chat session.

At this point, there are potentially two different use cases for the customer. Following are the persistent chat use cases the customer can have, and how you configure Amazon Connect to provide them.

Use case 1

The customer wants to continue their past chat session but they want to hide the post-chat survey. You use the following configuration to provide this experience.

Request:

PUT /contact/chat HTTP/1.1 Content-type: application/json { "Attributes": { "string" : "string" }, "ContactFlowId": "string", "InitialMessage": { "Content": "string", "ContentType": "string" }, "InstanceId": "string", ... // other chat fields // NEW Attribute for persistent chat "PersistentChat" : { "SourceContactId":"2222222-aaaa-bbbb-2222-222222222222222" "RehydrationType":"FROM_SEGMENT" } }

Configuration

  • SourceContactId = 2222222-aaaa-bbbb-2222-222222222222222 (the contactId for C2)

  • RehydrationType = "FROM_SEGMENT"

Expected behavior

  • This configuration starts a persistent chat session from the specified past ended contact C2 (for example, 2222222-aaaa-bbbb-2222-222222222222222).

    Transcripts of past chat sessions C2 (2222222-aaaa-bbbb-2222-222222222222222) and C1 (11111111-aaaa-bbbb-1111-1111111111111) are accessible in the current persistent chat session. Note that chat segment C3 (33333333-aaaa-bbbb-3333-3333333333333) is dropped from the persistent chat session.

  • In this case, the StartChatContact response returns C2 (2222222-aaaa-bbbb-2222-222222222222222) as "ContinuedFromContactId".

  • The RelatedContactId for this persistent chat session is 2222222-aaaa-bbbb-2222-222222222222222 (C2).

Use case 2

The customer wants to continue the past chat session and see the transcript of the entire past engagement (and they don’t want to hide the post-chat survey). You use the following configuration to provide this experience.

Note

For the ENTIRE_PAST_SESSION rehydration type, specify the first contact (initial contactId) of the past chat session as the SourceContactId attribute.

Request:

PUT /contact/chat HTTP/1.1 Content-type: application/json { "Attributes": { "string" : "string" }, "ContactFlowId": "string", "InitialMessage": { "Content": "string", "ContentType": "string" }, "InstanceId": "string", ... // other chat fields // NEW Attribute for persistent chat "PersistentChat":{ "SourceContactId":"11111111-aaaa-bbbb-1111-1111111111111" // (first contactId C1) "RehydrationType":"ENTIRE_PAST_SESSION" } }

Configuration

  • SourceContactId = 11111111-aaaa-bbbb-1111-1111111111111 (C1)

  • RehydrationType = "ENTIRE_PAST_SESSION"

Expected behavior

  • This starts a persistent chat session from the most recently ended chat contact (C3). Transcripts of past chat sessions C3, C2 and C1 are accessible in the current persistent chat session.

  • In this case, the StartChatContact response returns 33333333-aaaa-bbbb-3333-3333333333333 (C3) as "ContinuedFromContactId".

  • The RelatedContactId for this persistent chat session is 33333333-aaaa-bbbb-3333-3333333333333 (C3)

Note

Chat linkages are cumulative. After chat sessions are linked, they carry over.

For example, if a contact (contactId C2) that belongs to a past chat session was linked to a contact (contactId C1) from a different past chat session, then a new persistent chat session created by linking C2 results in implicit linkage of C1 as well. The new persistent chat session will have the following linkage: C3 → C2 → C1

The past contactId, which the persistent chat session is continued from, is exposed in the ContinuedFromContactId field in the StartChatContact API response. It's also in the RelatedContactId field in the contact record for the contact

How to access past chat contact transcript for a persistent chat

Accessing the past chat transcript for persistent chat uses the existing NextToken pagination model. The initial call to GetTranscript on a newly started persistent chat session contains a NextToken in the response, if past chat messages exist. NextToken must be used to access the past chat transcript along with setting the ScanDirection to BACKWARD on the subsequent GetTranscript call to fetch past chat messages.

If there are multiple past chat messages, GetTranscript returns a new NextToken and the same process can be repeated to fetch more past chat transcripts.

Not supported: using StartPosition and contactId filters for persistent chat

Amazon Connect does not support using StartPosition and contactId filters on the GetTranscript call for transcript item attributes that are from the past chat.