Loading
Agentforce 連絡中心
目錄傳訊元件的 Apex 類別

目錄傳訊元件的 Apex 類別

使用這些範例 Apex 類別可處理 Meta 產品目錄,並將目錄資料傳回至 WhatsApp 傳訊元件。

多產品訊息的範例 Apex 類別

此範例 Apex 類別傳回多產品訊息的 RichMessaging.CatalogSection 物件清單。如需如何建立 Apex 類別的詳細資訊,請參閱 建立 Apex 類別

備註
備註 針對多產品訊息,請建立 RichMessaging.CatalogSection 清單。
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;
    }
}

單一產品和目錄訊息的範例類別實作

將此範例類別實作用於單一產品與目錄訊息。該類別會實作 RichMessaging.ProcessCatalogOrderHandler 介面。

global class MyProcessCatalogOrderHandler implements RichMessaging.ProcessCatalogOrderHandler {
    global RichMessaging.ProcessCatalogOrderResult processCatalogOrderRequest(
            RichMessaging.ProcessCatalogOrderRequest catalogOrderRequest) {
        return new RichMessaging.ProcessCatalogOrderResult(
            RichMessaging.ProcessCatalogOrderResultStatus.SUCCESS, null, 'order-ref-123');
    }
}
 
正在載入
Salesforce Help | Article