logo Live Chat

How to Send Messages from Apex

Author
Editorial Team – 360 SMS App

Salesforce Expert

19 Jan 2022

Send messages from Apex

Automation has paved several ways to accelerate business operations. And one of the crucial instances of automation in business is text automation. Automated texts have enabled employees to send texts at a defined time for meaningful interaction without being rigorously involved in text operations. This further helps employees to save time and focus on core business priorities. For automation, Salesforce offers various tools like Process Builder, Flows, Workflows, etc. Users can also send messages from Apex to automate text messages through coding.

What is Apex?

Apex stands for Advanced Programming Experience in Salesforce. It is an object-oriented programming language developed by salesforce.com. It allows developers to write code that works on the force.com platform and create SAAS applications accessing client-server interfaces and Salesforce.com’s back-end database. 

Besides, developers can make API calls to Flow.com and execute flow and transaction control statements using Apex. Users can initiate Apex Code from triggers on objects and Web service requests.

When to use and Send Messages from Apex

Users can automate and send messages using a process builder. Also, Flow builder is one of the Salesforce automation tools that help to automate a guided visual experience and start a behind-the-scenes business process. But, users can count on Apex when they need more capabilities than what is provided by Flow Builder. They can use Apex to accommodate more complex automation use-cases.

How to Send Messages from Apex

Apex class can be executed in Process Builder, Flows, or trigger code.

Certain parameters need to be defined to send messages using Apex.

The Apex classes accept parameters in a comma-separated string.

  • Select action name as send SMS APEX
  • Select Apex class as send SMS from Process Builder
  • Set Apex variable and define parameters.

Param1: Add the Id of the primary object from which you are triggering the message. This should match your template object. Also, the outbound SMS will relate to this Salesforce primary object only. 

Param2: The API name of the phone field for that object or an actual valid phone number.

Param3: This parameter can be any one of the three-  

  • An SMS template Id, or
  • A question Id, or
  • A string

Template Id: 

You can extract a Template Id from the URL of an SMS template. Its object should match the Salesforce object defined in Param1. 

Question Id: 

Add a question Id of the first Survey question, which you want to trigger. After triggering the Survey’s first question, all responses will be handled automatically. 

String (Straight Text): 

You can add a string in this parameter if you do not want to use templates. This works well for simple text messages. The string also supports ‘Merge tags’. For example, Okay {Contact.firstname}. This is a message template.

Param4: Add an outbound phone number that you want to use to send an outbound text. It will pick the default phone number for the org or the first phone number mentioned in the 360 SMS user configuration tables if Param4 is blank.

After defining parameters, you are all set to automate messages.

Automate Salesforce SMS without complex coding

Pick the Best-Suited Tool and Minimize Effort

Though there are different tools available in Salesforce to automate text messages, every tool has its own importance and unique capabilities. With adequate knowledge of tools like Process Builder, Apex code, etc., business ventures can use the appropriate method to automate and send text messages. This helps them pick the best-suited tool, minimize team effort and perform text operations at a much faster rate.

To know more about no-code and standard automation in Salesforce, turn to our experts at sales@360smsapp.com or contact us here.

Recent Blogs

SMS Text Surveys for Business: How to Run Them in Salesforce and Actually Get Responses
Business Text Messaging 10 Oct 2026
SMS Text Surveys for Business: How to Run Them in Salesforce and Actually Get Responses

98% open rates. Responses in under 90 seconds. And yet most teams are still emailing surveys out and calling it…

Author
Editorial Team – 360 SMS App
Salesforce Expert
Read More icon
Top WhatsApp Apps for Zoho CRM in 2026: Features, Pricing, and How Natively They Actually Work
SMS App 09 Oct 2026
Top WhatsApp Apps for Zoho CRM in 2026: Features, Pricing, and How Natively They Actually Work

You’re already on Zoho CRM. Your customers are on WhatsApp. Most of them ignore emails and pick up a WhatsApp…

Author
Editorial Team – 360 SMS App
Salesforce Expert
Read More icon
Salesforce Built a 7-Agent AI Workforce. Here Are the 8 Roles Still Missing
Salesforce Release 09 Oct 2026
Salesforce Built a 7-Agent AI Workforce. Here Are the 8 Roles Still Missing

That headline from Dreamforce 2026 landed differently from the usual Salesforce announcements. Not “we’re adding AI features.” Not “coming soon…

Author
Editorial Team – 360 SMS App
Salesforce Expert
Read More icon
CONTACT US

Get in touch- hear back
in an hour or less

Whether you need a 360 SMS demo, a pricing quote, or help with setup in Salesforce, our team is available 24x7 across the US, UK, AU, and IN.

24x7 global support
Average first response within an hour
Trusted by 60K+ users on Salesforce

Send us a message

We'll connect you with the right specialist.

Loading......

Please select country below.

captcha

refresh-icon

By submitting this form, I acknowledge that I have read and understand 360 Degree Cloud's Privacy Policy

We use cookies to enhance your browsing experience, serve personalized ads or content, and analyze our traffic. By clicking "Accept All", you consent to our use of cookies.