Loading
Mail Delivery Issue Impacting Email to Salesforce UsersRead More
Agentforce Contact Center
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Example: Apex Class for Time Selector Messaging Components

          Example: Apex Class for Time Selector Messaging Components

          Time selector messaging components send customers a prompt and a list of available time slots for them to choose from. To generate the list of time slots each time the component is sent, create an Apex class. The Apex class determines the time slot start time, duration, and time zone.

          Required Editions

          View supported editions.
          Checkmark This article applies to: Enhanced In-App Chat, Enhanced Web Chat v1, Enhanced WhatsApp, Enhanced Facebook Messenger, and Enhanced Apple Messages for Business, and Bring Your Own Channel
          X icon This article doesn’t apply to: Enhanced Web Chat v2, Standard Facebook Messenger, Standard and Enhanced SMS, and Enhanced LINE

          This Apex class provides example time slots at several intervals, each set by a pair of Datetime statements.

          Example
          Example
          public with sharing class MessagingTimeSlotOptions {
              
              @InvocableMethod
              public static List<List<RichMessaging.TimeSlotOption>> getTimeSlotOptions(){
                  List<List<RichMessaging.TimeSlotOption>> result = new List<List<RichMessaging.TimeSlotOption>>();
                  List<RichMessaging.TimeSlotOption> options = new List<RichMessaging.TimeSlotOption>{
                      new RichMessaging.TimeSlotOption(
                          Datetime.now().addHours(1),
                          Datetime.now().addHours(2)),
                      new RichMessaging.TimeSlotOption(
                          Datetime.now().addHours(3),
                          Datetime.now().addHours(4)),
                      new RichMessaging.TimeSlotOption(
                          Datetime.now().addHours(25),
                          Datetime.now().addHours(26)),
                      new RichMessaging.TimeSlotOption(
                          Datetime.now().addHours(27),
                          Datetime.now().addHours(28))
                  };
          
                  result.add(options);
                  return result;
              }
          }
           
          Loading
          Salesforce Help | Article