---
schema_version: "1"
id: b6fe3885830241e0a78d9c5211274fc549865bc2af25369cc2a9cc8df5ad7849
title: Apex Classes for Catalog Messaging Components
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/service/264-0-0/messaging_catalog_apex_examples.md
canonical_url: https://help.salesforce.com/s/articleView?id=service.messaging_catalog_apex_examples.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 25c3e293f0eab74e46094f8264f28423d1ae88fcd5311ffe1a3f5ba2814329b3
description: Use these example Apex classes to process a Meta product catalog and return catalog data to your WhatsApp messaging component.
products:
  - Service Cloud
  - Digital Engagement
release: "264"
---
# Apex Classes for Catalog Messaging Components

Use these example Apex classes to process a Meta product catalog and return catalog data to your WhatsApp messaging component.

## Sample Apex Class for Multi-Product Messages

This sample Apex class returns a list of RichMessaging.CatalogSection objects for a multi-product message. For more information on how to create an Apex class, see [Create an Apex Class](https://trailhead.salesforce.com/content/learn/projects/quickstart-apex/quickstart-apex-1).

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

Note For a multi-product message, create a list of RichMessaging.CatalogSection.

```java
public with sharing class GetCatalogSection {
    @InvocableMethod
    public static List<List<RichMessaging.CatalogSection>> getCatalogSection() {
        String title = 'Wallpapers';
        List<String> productIds = new List<String>();
        productIds.add('ymrgtcg9co');
        RichMessaging.CatalogSection catalogSection = new RichMessaging.CatalogSection();
        catalogSection.titleValue = title;
        catalogSection.productIdsValue = productIds;

        List<RichMessaging.CatalogSection> x = new List<RichMessaging.CatalogSection>();
        x.add(catalogSection);
        List<List<RichMessaging.CatalogSection>> y = new List<List<RichMessaging.CatalogSection>>();
        y.add(x);
        return y;
    }
}
```

## Sample Class Implementation for Single-Product and Catalog Messages

Use this sample class implementation for both single-product and catalog messages. The class implements the RichMessaging.ProcessCatalogOrderHandler interface.

```java
global class MyProcessCatalogOrderHandler implements RichMessaging.ProcessCatalogOrderHandler {
    global RichMessaging.ProcessCatalogOrderResult processCatalogOrderRequest(
            RichMessaging.ProcessCatalogOrderRequest catalogOrderRequest) {
        return new RichMessaging.ProcessCatalogOrderResult(
            RichMessaging.ProcessCatalogOrderResultStatus.SUCCESS, null, 'order-ref-123');
    }
}
```