Install xSMS<sup>2</sup> now
xSMS2 provides you API to handle complex functionality to send SMS. In xSMS new version you will get an additional feature to send SMS using xSMS API. What you need to do is just provide text message and a list of parameters to predefined static method.
  1. Class
  2. Method
  3. Input Parameters
  4. Parameter Data Type
  5. Output Parameter
And now, let's discuss how to get the most from xSMS API.  This section outlines features available to perform SMS messaging.
  1. Class


We use two class xsms.xSMS_API and xsms.xSMS_API_Params to perform SMS messaging. Class xsms.xSMS_API has a global static method which is exposed to developer. This static method take two input parameters as text message that you want to send as “String” and list of phone number to whom you want to send SMS in the form of “List<xsms.xSMS_API_Params>”.

Class xsms. xSMS_API_Params has predefined parameters which you need to specify in order to send SMS and to track if there is any problem in sending SMS’s. List of xsms.xSMS_API_Params class parameters.
S.No Parameter Name Data Type Required/Optional
1 whoId ID( Data Type) Optional
2 whatId ID( Data Type) Optional
3 mobileNumber String Required
4 isError Boolean Optional*(Result Parameter)
5 errorMessage String Optional*(Result Parameter)

*After sending SMS you will get a list of xsms.xSMS_API_Params type as output parameter and you can check this parameter for the success and failure of your SMS.

Note: You need to specify “xsms” as prefix to class name. “xsms” is used as Namespace in Product xSMS2.
2. Method
Class xsms.xSMS_API has a static method “sendSMS” which is used to send SMS. This static method take two input parameters as text message that you want to send as “String” and list of phone number to whom you want to send SMS in the form of “List<xsms.xSMS_API_Params>”.
This method has return type as “List<xsms.xSMS_API_Params>”. This is the same list that we passed to the method as input parameter, but the difference is that later is the updated one having information about success and failure of sending SMS Process.
Method Signature: xsms.xSMS_API.sendSMS(String, List<xsms.xSMS_API_Params>);

3. Input/Output Parameters
Static method “sendSMS” take two input parameters. List of parameters for static method responsible for sending SMS’s
S.No. Input/Output Prameter Data Type Description
1 Input Parameter String Text message you want to send.
2 Input Parameter List<xsms.xSMS_API_Params> List of mobile number and Contact or Lead Id’s in the form of xsms.xSMS_API_Param class whom you want to send SMS.
3 Output Parameter List<xsms.xSMS_API_Params> Update list having result of sending SMS process.
How to Send SMS
  Step - 1
Initialize a String parameter with the text you want to send as SMS.
For example:  String textMessage = ‘Hi, Thank you for showing your interest in our product.’
Character Support: UTF-8, Unicode
Limitation:  Message length should not be greater than 160.
Note: You can not specify different SMS text for individual mobile number. A common SMS text will be sent to all mobile number added in the “xSMS_API_PARAM” List (Step2).
Step - 2
Once you have done with SMS text you need to create a list of xSMS Parameters. xSMS API has a class named “xSMS_API_Params”.
This class has three variables such as:  whoId, whatId and mobileNumber.

1. Create a List of type “xSMS_API_Params”.

List<xsms.xSMS_API_Params> apiParameterList = new List<xsms.xSMS_API_Params>(); Note: This list along with the textMessage string will be passed as parameters.

2. Create an instance of the class “xSMS_API_Params”.

xsms.xSMS_API_Params paramObject = new xsms.xSMS_API_Params();
Note: You need to specify “xsms” as prefix to class name. “xsms” is used as Namespace in Product xSMS2.    

3. Initialize the above described parameters.

First, specify Id of a Salesforce contact or lead to whom you want to send SMS
paramObject.whoId =”contactId”. OR paramObject.whoId =”leadId”.
Note: You can specify either contactId or LeadId for a single instance of the class “xSMS_API_Params”.

Second, specify the Id of a Salesforce Account, Asset, Campaign, Case, Contract, Opportunity, Product or Solution record.
paramObject.whatId =”testId”.

Third, specify the mobile number to which you want to send SMS.
paramObject. mobileNumber=”91-3214567654”.
Note: Mobile number should be in format “countrycode-mobilenumber”.

Valid Mobile Number:  ”91-3214567654”.
Invalid Mobile Number:  “3214567654”.
Invalid Mobile Number:  “913214567654”.

Fourth, Now add this instance to the list.
Note:  Similarly, you can add more instance of the class xSMS_API_Param to this list, if you want to send SMS to more than one mobile numbers.
Step - 3
We assume that you have completed Step1 and Step2.
Now pass the parameters (textMessage, apiParameterList) to method “sendSMS”. This is a static method so use class name to call this method.
xsms.xSMS_API.sendSMS(textMessage, apiParameterList);
This method will send SMS to mobile numbers added in the list and create “Task” for all specified Contact Id’s or Lead Id’s in the list.
This process will help you to send SMS using “xSMS API”.
Real Time Example
Now as I have explained everything about xSMS API let us take a real time scenario to check how it works.
Here I am taking the example of send SMS on CaseComment creation to the Case Contact.
There are some prerequisite such as Mobile number and Mobile Phone Country on Contact should be available.
Now create a trigger on “CaseComment” object.

Example: Trigger on CaseComment Object
After creating the trigger, now go to your case and create a comment. A text message that you have specified will be sent to Case Contact.
You can check the Activity History list for that Case Contact to confirm the SMS status.
Note: If you want to send SMS to a number whose record is not in your organization, you just need to specify text message and List of  mobileNumber(xsms.xSMS_API_Params). As you saw in CaseComment trigger example line 18, method will return a list and you can check this list to confirm your SMS status.

Hope this document helps you to understand how you can use “xSMS API” for sending SMS.
xSMS API based SMS process is subject to Governor Limits.
For any query or assistance please feel free to contact us at: