Skip to main content

Personalize Guided Shopping with Context-Aware Messaging

Learning Objectives

After completing this unit, you’ll be able to:

  • Explain the relationship between context variables, the messaging session object, and messaging session fields.
  • Summarize the role that context variables for messaging sessions play in context-aware conversations for an agent.
  • Outline the steps to connect messaging session variables to your agent’s actions.

Context-Aware Messaging

Agentforce Guided Shopping Agents are designed to meet the growing customer expectation for personalized and seamless online shopping experiences across all channels and devices. They achieve this through context-aware messaging and advanced AI, which enables them to dynamically adapt conversations using customer-specific data. The result is a more engaging customer experience.

To enable context-aware messaging for your agent, you need to integrate context variables, the Messaging Session object, messaging session record fields, and agent topic action inputs.

  • Context variables: These are containers that hold specific pieces of information about a messaging session. These variables are dynamic and can pull data from the Messaging Session object. They allow Salesforce to personalize interactions by using data relevant to the customer or session. For example, a context variable might store the customer’s name or locale.
  • Messaging Session object: This is the backbone of a messaging session. It stores all the data related to a specific session, such as the session ID, customer information, and other metadata. Think of it as a database record that tracks everything happening in a session.
  • Messaging session fields: These are the individual fields within the Messaging Session object. Each field holds a specific piece of information, such as:
    • Session ID: A unique identifier for the session.
    • Messaging User ID: Links the session to the customer.
  • Topic action inputs: These are instructions or actions that agents can perform during a session. They often rely on context variables to provide the necessary data for these actions.

Here’s how they work together.

  1. Data flow: The Messaging Session object stores all session-related data. Messaging session record fields are the individual pieces of this data.
  2. Context variables: These variables pull data from the Messaging Session object and make it accessible during the session.
  3. Agent topic action inputs: These inputs use context variables to perform specific actions, ensuring that agents have the right data at the right time.

Example:

  1. A shopper starts a chat asking if the product in their cart is available at a local store.
  2. The Messaging Session object, MessagingSession UserLocale__c, stores the user’s location in the UserLocale data field.
  3. The context variables User Locale__c maps the location value to the appropriate topic action inputs.
  4. Topic actions assigned to the agent use the location value to determine if stores in the shopper’s locale have the product in inventory.

Create Context Variables for Messaging Sessions

Context variables let your agent use messaging session record fields as inputs to send site context to the agent.

  1. In your Salesforce org, click Setup and select Setup.
  2. Select the Object Manager tab.
  3. In the Quick Find box, enter and select Messaging Session.
  4. Click Fields & Relationships | New.
  5. For each new field:
    • Select Text as the data type, and create these field labels with a length of 255 characters.
      • Basket ID: BasketId
      • Currency: Currency
      • Domain URL: DomainURL
      • IsCartMgmtSupported: IsCartMgmtSupported
      • Organization ID: OrganizationId
      • Query Facets: QueryFacets
      • Refresh Token: RefreshToken
      • Site ID: SiteId
      • UsID: UsId
      • User Locale: UserLocale
    • Accept the default values for field-level security, and click Next.
    • Save your new field.

Add Context Variables to Agent Conversations

You connect messaging session record variables to the actions assigned to your Guided Shopping Agent. The record variables allow your agent to connect chat session input to generate a helpful agent response. To add these fields to agent conversations, map the messaging session fields to the agent context variables. Then, assign these variables to the agent’s actions.

Note

Variables are supported only for Service Agents for Messaging for In-App and Web channels. Your Guided Shopping Agent is a service agent.

  1. In your Salesforce org, click Setup and select Setup.
  2. In the Quick Find box, enter and select Agentforce Agents.
  3. Select the name of your Guided Shopping Agent for B2C, then select Open in Builder.
  4. On the Context tab, click Messaging Session Record Variable.
  5. Click Edit Included Fields.
  6. Select these Messaging Session fields, then click Save Included Fields.
    • Basket ID: BasketId
    • Currency: Currency
    • Domain URL: DomainURL
    • IsCartMgmtSupported: IsCartMgmtSupported
    • Organization ID: OrganizationId
    • Query Facets: QueryFacets
    • Refresh Token: RefreshToken
    • Site ID: SiteId
    • UsID: UsId
    • User Locale: UserLocale

Include messaging session fields to agent conversations.

On the Topics tab for each of the following topics, assign messaging variables to each topic action.

  • B2C Commerce Product Search Assistant
  • B2C Commerce Order Assistant
  • B2C Product Details
  • B2C Commerce Cart Management.
  1. Click the topic.
  2. Click this Topic’s Actions.
  3. Click an action.
  4. Locate Inputs and in the appropriate Assign a Variable field, enter the values as shown in the table.
  5. Repeat for each action.
  6. Save your work.

Input

Variable to Assign

Site ID

MessagingSession SiteId__c

Organization ID

MessagingSession OrganizationId__c

Locale

MessagingSession UserLocale__c

Customer Unique Identifier

MessagingSession UsId__c

IsCartMgmtSupported

MessagingSession IsCartMgmtSupported__c

Add messaging session variables to select action inputs.

Sum It Up

In this unit, you learned how context variables work to personalize Guided Shopping Agent conversations by storing prechat values, which contain information about the customer. In the next unit, learn how to help your agent answer frequently asked questions.

Resources

Share your Trailhead feedback over on Salesforce Help.

We'd love to hear about your experience with Trailhead - you can now access the new feedback form anytime from the Salesforce Help site.

Learn More Continue to Share Feedback