logo Live Chat

How to Send Messages from Apex

Author
Siddharth Sehgal

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.

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

Salesforce CTI Integration in 2026: How It Works, Best Apps, and Setup Guide
CTI 14 Sep 2026
Salesforce CTI Integration in 2026: How It Works, Best Apps, and Setup Guide

The call comes in. Your agent’s already in Salesforce, but the phone’s a separate app. They’re asking the customer to…

Author
Siddharth Sehgal
Read More icon
WhatsApp Business Pricing in 2026: What Zoho CRM Users Actually Pay
SMS App 11 Sep 2026
WhatsApp Business Pricing in 2026: What Zoho CRM Users Actually Pay

WhatsApp isn’t a nice-to-have channel anymore. For a lot of businesses in 2026, it’s where the actual customer conversations happen:…

Author
Editorial Team – 360 SMS App
Salesforce Expert
Read More icon
How to Use Agentforce AI Agents for Two-Way SMS and WhatsApp in Salesforce (2026 Guide)
SMS App 09 Sep 2026
How to Use Agentforce AI Agents for Two-Way SMS and WhatsApp in Salesforce (2026 Guide)

Most Salesforce teams hear “Agentforce” and assume it’s something they need to go set up separately — a new product,…

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.