Skip to main content

How to Create Manual Round Robin ID in Salesforce

How to send sms using third party sms APIs from Salesforce ?

How to send SMS using third party sms APIs from Salesforce ?

In this blog I will explain how we can send SMS using a third party API service.

You can buy sms from any bulk sms provider, there are tons of bulk sms provider online. Just make sure they are providing API also.

First of all you have to add your bulk sms provider's website in Remote Site Settings. To add the website in Remote Site Settings please follow below steps : 

  1. From Setup, enter Remote Site Settings in the Quick Find box, then select Remote Site Settings.
  2. Click New Remote Site.
  3. Enter a descriptive term for the Remote Site Name.
  4. Enter the URL for the remote site.
  5. Optionally, enter a description of the site.
  6. Click Save.
After adding remote site you can make the callouts to your service provider's website. For testing purpose I am creating a custom Visualforce page with a Sign Up button.

I will be sending the SMS on the click of Sign Up button.

To send the sms on button's click let's create an APEX class as shown below : 

sendSMSCTRL

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
Public class sendSMSCTRL{
    public sendSMSCTRL(){
        
    }
    public void sendSMS(){
        String msg = 'Hello';
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        request.setEndpoint('http://yourwebsite.com/api/sendSMS.asp?username=YOURUSERNAME&password=XXXXX&sender=MYTEST&sendto=8890288555&message='+msg);
        request.setMethod('POST');
        request.setHeader('Content-Type', 'application/json;charset=UTF-8');
        request.setBody('{"name":"testing"}');
        HttpResponse response = http.send(request);
        if (response.getStatusCode() != 201) {
            System.debug('The status code returned was not expected: ' +
                response.getStatusCode() + ' ' + response.getStatus());
        } else {
            System.debug(response.getBody());
        }
    }
}


In above code I am making a HTTP callout using POST method to my service provider's API url with all the required parameters.

You can also send the parameters as JSON encrypted format.

Now let's create a Visualforce page : 

sendSMS

1
2
3
4
5
<apex:page controller="sendSMSCTRL">
    <apex:form>
        <apex:commandButton value="Sign Up" action="{!sendSMS}" />
    </apex:form>
</apex:page>


In above VF page I have just created a button to send the SMS. On click of that button my VF page will call my Apex method sendSMS() and trigger the sms process.

You can add the parameters dynamically as per your requirement.



If you have any question please leave a comment below.
If you would like to add something to this post please leave a comment below.
Share this blog with your friends if you find it helpful somehow !

Thanks
Keep Coding 😊











Comments

  1. Your contents are completely awesome and share worthy. I really appreciate your efforts that you put on this. Keep sharing. For more SMS Service Provider related information visit NORSMS


    ReplyDelete

Post a Comment

Popular posts from this blog

How to send WhatsApp from Lightning Component Salesforce ?

Send WhatsApp from Lightning Component SalesforceHi folks, in this article I will explain how you can send WhatsApp from Lightning Component using https://wa.me/
In this example I will create a Quick Action button on Contact which will be connected with my Lightning Component.
Please follow the steps below : 
Step 1 : Create a Lightning Component & Apex as shown below
WhatsApp.cmp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30<aura:componentcontroller="Vlog_whatsappCTRL"implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction"access="global"><aura:attributename="recordId"type="String"/><aura:attributename="con"type="Contact"/><aura:attributename="msg"type="String"/><aura:handlername="init"action…

Send WhatsApp and Save Chat using Lightning Component Salesforce | Salesforce Tutorials

Hello folks,
In this article you will learn to send WhatsApp and Save the Chat using Lightning Component Salesforce. 
Prerequisite : 
Create a custom object WhatsApp__c
Create custom fields as shown below : 


Please follow the code below : 

WhatsAppComponent 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30<aura:componentcontroller="Vlog_whatsappCTRL"implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction"access="global"><aura:attributename="recordId"type="String"/><aura:attributename="con"type="Contact"/><aura:attributename="msg"type="String"/><aura:handlername="init"action="{!c.doInit}"value="{!this}"/><articleclass="slds-card"><divclass="slds-card__header…

Get Parent Id when overriding standard actions with a Lightning Component in salesforce1 app

How to Get Parent Id when overriding standard actions with a Lightning Component in salesforce1 app ?
In this blog I will explain how you can get Parent Id when overriding standard actions with a lightning component.
For example I have changed my Opportunity New button action with a custom Lightning Component. 
Let's create a new account and from the related tab try creating the new Opportunity. Have you noticed any change in URL ?
Let me share the URL with you :  _________________________________________________________________________ https://kapilbatra1-dev-ed.lightning.force.com/lightning/o/Opportunity/new?recordTypeId=0127F000000htlpQAA&additionalParams=accid%3D0017F00002S6g9H%26&inContextOfRef=1.eyJ0eXBlIjoic3RhbmRhcmRfX3JlY29yZFBhZ2UiLCJhdHRyaWJ1dGVzIjp7Im9iamVjdEFwaU5hbWUiOiJBY2NvdW50IiwicmVjb3JkSWQiOiIwMDE3RjAwMDAyUzZnOUhRQVIiLCJhY3Rpb25OYW1lIjoidmlldyJ9LCJzdGF0ZSI6e319&count=3 _________________________________________________________________________
In above URL you …