How to Create a Batch Scheduler that Runs at Midnight
Business ventures come across different automation requirements now and then. There can be specific text automation use-cases that are pretty simple to implement. But on the other hand, there can be complex SMS automation use-cases too, that can be difficult to achieve without extensive coding knowledge. For instance- Creating a batch scheduler that runs midnight also requires coding knowledge.
Many times automation requirements can be fulfilled by simple no-code automation itself.
For example, 360 SMS provides no-code point-and-click automation capability that allows even non-coders to automate text messages.
But many intricate automation use-cases are not possible without coding. Thus, users can count on Apex codes to cater to such automation requirements. Here’s one example:
Example of Complex Automation Use-case
When a customer sends an MMS, it gets stored under notes and attachments. So, if a firm wants to trigger an SMS immediately in the event of an incoming file, this automation is not possible without coding. There’s a Salesforce limitation that you cannot apply automation to the Notes and Attachments object. Hence, you can count on Salesforce standard automation and use the Apex class for such automation cases.
Now here’s another use-case where you can run a batch scheduler using Apex class.
Use-case for Sending Messages Daily at Midnight
Without a doubt, good customer experiences and service are the keys to unlocking a customer’s loyalty. So, you could be the first one to wish your customers on their special days like birthdays, anniversaries, and other life events.
Say you want to send a birthday greeting to your customers in bulk at midnight, it is not necessary to be present in the office at midnight to send time-sensitive messages. You can take the developer’s assistance for automation through Apex codes and batch scheduler. This way, organizations can send messages at a specified date and time. Also, they can control the frequency of scheduled text messages and decide whether they want to run the batch scheduler once or repeatedly.
How to Create a Batch Scheduler that Runs Midnight
The batch scheduler is basically used to schedule and send text messages in bulk. Users can also trigger a batch scheduler on the completion of a defined action.
So here’s the process to run the batch scheduler at midnight:
- Firstly, you have to write a schedulable Apex class.
The Apex is an object-oriented programming language that allows developers to develop business applications as per the requirement or execute the flow and the transaction control statements on the Lightning platform.
So, in Apex class, you have to mention the requirement you want to fulfill or the action you want to perform, or we can say a use-case. More importantly, you need to execute the SMS app APIs in the Apex class only to send SMS. Also, you can define the criteria if you wish to send SMS to specific recipients who fulfill the given criteria.
APIs are used to integrate Salesforce with 360 SMS app through coding. This enables users to send and receive text messages.
- Further, if you want to run a batch scheduler only once, you can execute it simply by specifying the date and time. But if you wish to run a batch scheduler repeatedly at a specific time, then you have to write a CRON job or an expression. The CRON job is written if something is not specified particularly. For example, the date is not specific if someone wants to run a batch class daily.
A CRON expression is a sequence of five or six fields separated by white spaces that indicates the set of times as a schedule to execute some class.
CRON Expression Example to Configure Batch Scheduler that Runs Midnight Daily
Expression– 0 0 0 ? * * *, Description– at 12:00 AM every day
NOTE: An Apex class should be schedulable. Only then you can schedule the messages from the developer console.
After this entire process, the batch scheduler runs automatically at the specified time.
How to Stop Scheduled Messages
Even if you want to stop the flow of scheduled messages, you can navigate to the Scheduled Jobs page. On this page, you can find all the jobs scheduled so far. So, you can search the name of the job and delete it.
Choose the Best-Suited automation technique and Achieve Desired Goals Conveniently
No matter whether you’re looking to implement automation to a simple or a complex use-case, 360 SMS allows you to do that easily. On the one hand, you can opt for point-and-click no-code automation to handle simple use-cases yourself. On the other hand, you can put developers at work and opt for an Apex class and a batch scheduler for complex automation use-cases and send messages at midnight daily. Thus, you can choose the most case-appropriate method depending on the use case and achieve the desired outcome conveniently.
To know more about automation techniques for coders and non-coders, get in touch with our experts at sales@360smsapp.com or contact us here.