---
schema_version: "1"
id: b137b45b3e2f165df5ddbf634de028ae40de01895786f399465af902d95100d6
title: Persist Pre-Chat Inputs Across Messaging Sessions
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/service/264-0-0/miaw_handle_sessions.md
canonical_url: https://help.salesforce.com/s/articleView?id=service.miaw_handle_sessions.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 70fea0585e40bb5fddd38312a780d61a0b788b144b8d734e41b0ce5f0199745b
description: An Enhanced Chat session ends when the service rep selects End Chat. If a customer continues to send messages, a new session is created. The conversation continues seamlessly from the customer’s perspective, but the rep loses access to the original pre-chat data. These instructions let service reps access pre-chat data across sessions. It’s not necessary to set up access to pre-chat data if you’re already using User Verification to persist messaging history.
products:
  - Service Cloud
  - Digital Engagement
release: "264"
---
# Persist Pre-Chat Inputs Across Messaging Sessions

An Enhanced Chat session ends when the service rep selects End Chat. If a customer continues to send messages, a new session is created. The conversation continues seamlessly from the customer’s perspective, but the rep loses access to the original pre-chat data. These instructions let service reps access pre-chat data across sessions. It’s not necessary to set up access to pre-chat data if you’re already using User Verification to persist messaging history.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition">
        <colgroup>
          <col style="width:50%">
          <col style="width:50%">
        </colgroup>
        <tbody>
          <tr class="">
            <td class="slds-cell-wrap" colspan="2" style="vertical-align:top;"><a href="https://help.salesforce.com/s/articleView?id=service.messaging_editions.htm&amp;type=5&amp;language=en_US" target="_blank">View supported editions.</a></td>

          </tr>
          <tr class="">
            <td class="slds-cell-wrap" style="vertical-align:top;">
              <a name="miaw_handle_sessions__d683e335"><!-- --></a><span style="vertical-align:text-bottom;display:inline-block;"><img style="margin-bottom:0;" id="miaw_handle_sessions__d683e335" src="https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-service-support_channels-264-0-0-production-enus/f3c4b3d2-ff86-4f7c-9fe2-3d8b23d35109/resources-global/_corporate/images/checkmark.png" alt="Checkmark"></span>
              <strong>This article applies to:</strong>
            </td>

            <td class="slds-cell-wrap" style="vertical-align:top;">Enhanced In-App Chat and Enhanced Web Chat channels</td>

          </tr>
          <tr class="">
            <td class="slds-cell-wrap" style="vertical-align:top;">
              <span style="vertical-align:text-bottom;display:inline-block;"><img style="margin-bottom:0;" src="https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-service-support_channels-264-0-0-production-enus/f3c4b3d2-ff86-4f7c-9fe2-3d8b23d35109/resources-global/_corporate/images/crossmark.png" alt="X icon"></span>
              <strong>This article doesn’t apply to:</strong>
            </td>

            <td class="slds-cell-wrap" style="vertical-align:top;">Enhanced WhatsApp, Enhanced Facebook Messenger, Standard and Enhanced SMS,
              Enhanced Apple Messages for Business, Enhanced LINE, and Bring Your Own
              Channel</td>

          </tr>
        </tbody>
      </table> <table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small permission">
        <colgroup>
          <col style="width:50%">
          <col style="width:50%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="colgroup" class="slds-cell-wrap" colspan="2" style="text-align:center;vertical-align:top;" id="d124940e95">User Permissions</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="User Permissions" class="slds-cell-wrap" style="vertical-align:top;" headers="d124940e95 ">To set up Omni-Channel Flow and Enhanced Chat:</td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d124940e95 ">Customize Application</td>

          </tr>
          <tr class="">
            <td data-label="User Permissions" class="slds-cell-wrap" style="vertical-align:top;" headers="d124940e95 ">To modify permission sets and profiles:</td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d124940e95 ">Manage Profiles and Permission Sets</td>

          </tr>
        </tbody>
      </table>

Before you begin, you must have an Omni-Channel flow that already handles pre-chat data. To learn more, see [Map Pre-Chat Values in Omni-Channel Flow](https://help.salesforce.com/s/articleView?id=service.miaw_map_messaging_2.htm&release=264.0.0&type=5 "Omni Flow sends pre-chat form data to the messaging session for a more informed service rep experience. Map visible and hidden fields from your pre-chat form to your Omni flow.").

Since pre-chat data isn’t stored across sessions by default, you must store this data in a Salesforce record during the first session. Then, update your Omni-Channel flow to access this data from subsequent sessions. Your updated flow looks up this information using the `ConversationId` field of the Messaging Session record, which is the same across sessions.

![Important](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-service-support_channels-264-0-0-production-enus/f3c4b3d2-ff86-4f7c-9fe2-3d8b23d35109/images/icon_important.png)

Important This scenario is more likely to occur in Enhanced In-App Chat where a customer can continue a conversation long after the service rep has ended the chat. However, it can also occur with Enhanced Web Chat customers when the customer sends more messages from the same messaging window.

1. From Setup, in the Quick Find box, enter Flows, and then select **Flows**.
2. Find and select your previous flow from the list.
3. Before handling the pre-chat input variables or routing the work, add a check to determine if we have a pre-existing session from the same conversation. If so, we use that information to repopulate the input variables.
    1. Use a **Get Records** element to get the current messaging session using the `recordId` input.
        
        ![Diagram of get current session flow element.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-service-support_channels-264-0-0-production-enus/f3c4b3d2-ff86-4f7c-9fe2-3d8b23d35109/support_channels/images/miaw/miaw_current_session.png)
    2. Use a **Get Records** element to find a pre-existing messaging session with the same `ConversationId` as the current messaging session. We also make sure that the `Id` isn’t the same as the current messaging session. In this example, we sort the results by creation date so that we can ensure that the first result is the first session. We then only return the first result.
        
        ![Diagram of get previous session flow element.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-service-support_channels-264-0-0-production-enus/f3c4b3d2-ff86-4f7c-9fe2-3d8b23d35109/support_channels/images/miaw/miaw_previous_session.png)
    3. To determine if this session is the first messaging session, use a **Decision Tree** element and check if the previous result is null.
        
        ![Diagram of decision tree flow element.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-service-support_channels-264-0-0-production-enus/f3c4b3d2-ff86-4f7c-9fe2-3d8b23d35109/support_channels/images/miaw/miaw_session_decision.png)
    4. If this session is the first messaging session, no action is necessary.
    5. If this session _isn’t_ the first messaging session, extract the pre-chat information from wherever you previously stored it and put it in the correct input variables. In this example, we extract the values from custom fields in the original Messaging Session record.
        
        ![Diagram of get previous session flow element.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-service-support_channels-264-0-0-production-enus/f3c4b3d2-ff86-4f7c-9fe2-3d8b23d35109/support_channels/images/miaw/miaw_session_assignments.png)
    6. After this new logic, you can handle the pre-chat input variables and route the work in just the same way as you did in your original flow.
4. The following screenshot illustrates what your new flow could look like. The new logic is highlighted.
    
    ![Diagram of Omni-Channel Flow that works across multiple sessions.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-service-support_channels-264-0-0-production-enus/f3c4b3d2-ff86-4f7c-9fe2-3d8b23d35109/support_channels/images/miaw/miaw_prechat_sessions_flow.png)
5. Click **Done**.
6. Save this flow as a new version, and verify that it’s activated in your org.

#### See Also

- [Persist Secure Messaging History Across Multiple Devices with User Verification](https://help.salesforce.com/s/articleView?id=service.user_verification.htm&release=264.0.0&type=5 "To maximize data privacy, securely connect your customers to their messaging history and persist conversations across devices with token-based or credential-based user verification. Persist conversations across devices with token-based user verification.")