Invocable Methods with multi parameters

Invocable methods can have only have one Input parameter, In order to pass multiple params in apex class one should use InvocableVariable annotations

Use Case: Send SMS using Process builder

In Order to send a SMS we need 2 params 1. To Number and other is 2. SMS Body and also consider optional param 3. Appointment Date

If we create an Apex Invocable method it has limitation of only one param which doesn't help in our above use case so to make it work we need to InvocableVariable

Following class is an SmsUtility which sends msg to mobile number (logic for sending msg is not included).

NOTE: Label='Send SMS' you need to search with same in process builder under action type Apex Class

global class SMSUtility {
    
    @InvocableMethod(label='Send SMS' description='method description')
    // here input param is smsRequest of List type
    global static void smsList(smsRequest[] requests){
        for (smsRequest request : requests) {
           ....
           now perform your logic with input params e.g., 	  

           request.toNumber, request.smsBody
           ....
        }
    }
    
    
    global class smsRequest {
        @InvocableVariable(required=true)
        global String toNumber;
        
        @InvocableVariable(required=true)
        global String smsBody;
        
        @InvocableVariable
        global String appointmentDate;
    }
    
}

Above InvocableVariable will be shown as Input in process builder as follows

Achieve multi params using InvocableVariables in InvocableMethods

Feel free to comment for suggestions/help