Salesforce Time Selector Messaging Component

Salesforce Time Selector Messaging Component

Salesforce Time Selector Messaging Component can be used for Date Time Selection.

Sample Time Selector Component:

For example, we can use the Salesforce Time Selector Messaging Component in Enhanced Einstein BOT with the Time Selector component.

1. Create a Custom Object “Appointment” to store your Appointments.

I created Appointment Custom object with Start Time, End Time and Status.

2. Create the following Apex Class to fetch the available Appointments. This will be used in the Einstein BOT.

public class AppointmentSlots {
    
    @InvocableMethod
    public static List < List < RichMessaging.TimeSlotOption > > getAvailableSlots() {
        
        List < List < RichMessaging.TimeSlotOption > > availableSlots = 
            new List < List < RichMessaging.TimeSlotOption > >();
        List < RichMessaging.TimeSlotOption > tempSlots = 
            new List < RichMessaging.TimeSlotOption >();
        
        for (
            Appointment__c objAppt : [
                SELECT Appointment_Start_Time__c, Appointment_End_Time__c
                FROM Appointment__c 
                WHERE Status__c = 'Available'
                AND Appointment_Start_Time__c >= TODAY
            ]
        ) {
            
            tempSlots.add(
                new RichMessaging.TimeSlotOption(
                    objAppt.Appointment_Start_Time__c,
                    objAppt.Appointment_End_Time__c
                )
            );
            
        }
        
        availableSlots.add(
            tempSlots
        );
        return availableSlots;
        
    }
    
}

3. Create the following Auto-Launched Flow to update the Appointment record after the user selection.

4

. Use Apex Action to get the Time Slots.

5. Use Time Selector to Display the Time Slots.

6. Use Flow to update the Appointment record.

Output:

Leave a Reply