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

To set up persistent chat, when you call the StartChatContact API to create a new chat contact, you provide the previous contactId in the SourceContactId parameter of StartChatContact API. This invokes a process called chat rehydration: chat transcripts are pulled from previous chat contacts, and displayed.

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 a persistent chat session

To enable persistent chats, specify the PersistentChat request parameter in the StartChatContact API.

Note

For persistent chat, ensure that your instance's S3 bucket for chat transcripts contains the past contact's transcript.

Using multiple chat transcript buckets or changing the chat transcript file name that is generated by Amazon Connect is not supported for persistent chats.

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 contact 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.