Skip to content
Log in

Configure your store for the AI agent

On this page

Set up a standard embedded service deployment

  1. In the Salesforce Setup, go to Feature Settings > Digital Experiences > Settings.

  2. Select the Enable Digital Experiences option and Save.

  3. Go to Feature Settings > Service> Omni-Channel > Routing Configurations.

  4. Create a new routing configuration:

    • Name e.g. Steve Sales Rep Routing

    • Routing Priority 1

    • Routing Model Most Available

    • Units of Capacity 2.0

  5. Save.

Create a fallback queue

  1. Go to Users > Queues and create a new queue with Messaging Session enabled. This will be your fallback queue when the agent is not active.

  2. Set the Routing Configuration to be the one you created previously.

    Fallback queue

Add a flow

  1. Go to Flows and select New Flow.

  2. Set the Flow Type to Omni-Channel Flow. If you can’t see the option, you may need to switch on the Omni-Channel option in your Salesforce settings.

    OmniChannel Flow type

  3. In the element manager, create 3 new text variables with inputs enabled. Call them recordId, storeId, and customerId (case sensitive).

  4. Create a Get Records element which will query MessagingSession records where the record id = the recordId input variable.

  5. Update the MessagingSession record with the recordId, saving it to a custom field ‘StoreId__c’ (can be a text or lookup field to the Store record).

  6. (Optional) To associate the session with a known customer: add a Get Records element to look up a Contact where s_c__Id__c equals the customerId variable. If a match is found, add an Update Records element to set the ContactId field on the MessagingSession record. This links the session to the customer’s record before the agent takes over.

  7. Create a ‘Route Work’ action and enter the following:

    • Set the Record Id Variable to be recordId,

    • Service Channel to be ‘Messaging’,

    • Route To ‘Agentforce Service Agent’

    • Agentforce Service Agent to your Agent

    • Fallback Queue to the queue record you created before.

      Configure omniflow flow

  8. Save and activate the flow.

Create a new channel

  1. Go to Setup > Messaging settings.

  2. Select New Channel.

  3. Select Next and select Enhanced Chat.

  4. Select Next.

  5. Enter a channel name, set the deployment type to Web, and enter your store’s domain (you can find this on your store record in StoreConnect).

  6. Select Next.

  7. Set Channel Routing to the omniflow you created previously, and set the Fallback Queue to the queue created previously.

    Channel routing setup

  8. Save.

Add custom parameters to the channel

  1. Go back to the Messaging Settings tab and select your new channel.

  2. Scroll to the Custom Parameters section and create two new parameters:

    Parameter 1 — store identity: - Name: storeId - Data Type: string, maximum length 18 - Save

    Parameter 2 — customer identity: - Name: customerId - Data Type: string, maximum length 36 - Save

  3. In the Parameter Mappings section, create mappings for both parameters:
    • Map storeId to the storeId flow variable name.
    • Map customerId to the customerId flow variable name.
  4. Go to Feature Settings > Service> Embedded Service > Embedded Service Deployments.

  5. Select Embedded Service Deployment

  6. In the Pre-Chat field section:

    • Activate the pre-chat feature.

    • Select both storeId and customerId in the Hidden Pre-Chat fields.

    • Save.

  7. You can customize the look and feel of the Agent here as well including avatars and branding.

  8. Once you have made your changes, select Publish.

  9. Copy the Chat Code snippet, you’ll use this on your StoreConnect site.

:::note Because StoreConnect manages its own customer authentication independently of Salesforce, Agentforce sessions always start as guest sessions. Passing customerId as a hidden pre-chat field and associating it with a Contact record in the Omni flow is how you give the agent context about who it is talking to. If the visitor is not logged in, the customerId field will be empty and the session proceeds as a true anonymous interaction. :::

Add the chat code snippet to the store

  1. Navigate to your store record and on the page navigate to the ‘Body Content’ field.

  2. Create or update a content block.

    Content block with chat code

    • Select No added styling as the Content Template.

    • Paste the chat code snippet into the Content field.

    • After the initEmbeddedMessaging function, add the following code to set the hidden pre-chat fields.

```liquid

    {% if current_store %}

      window.addEventListener("onEmbeddedMessagingReady", function() {
        embeddedservice_bootstrap.prechatAPI.setHiddenPrechatFields({
          storeId: "{{ current_store.id }}"{% if current_customer %},
          customerId: "{{ current_customer.Id }}"{% endif %}
        });
      });

    {% endif %}
    ```


    The `customerId` value is the StoreConnect UUID stored in the `s_c__Id__c` field on the Contact record. It is only set when a customer is logged in — for guest visitors the field is omitted and the session proceeds anonymously.
  1. Select Save.

:::tip For mid-session identity verification, Salesforce’s built-in OTP flow (email or SMS) lets you verify a customer’s identity during a conversation without requiring them to log in first. To use a tamper-proof signed token instead of a plain ID, see Embed Salesforce LWC components in your storefront. :::

Open your StoreConnect site and test the agent via the messaging window!

Was this article helpful?

Was this article helpful?