WHATSAPP INTEGRATION WITH SALESFORCE
Hola Trailblazer Community,
Hope you all guys are good.
So today i am planning to share my discovery with all of the trailblazer community. so from the headlines you might understood what i am going to share "Whatsapp Integration".
I have googled a lot for that how to integrate whatsapp account from CRM. Some python library also i have seen but no good luck in vain.
Last 2-3 months back i have seen that twilio has launched "Twilio Api for WhatsApp".
You can check pricing here.
With trail account you will get the sandbox. You can test your code there.
Here i will not share a lot of things but only i will share you can able to send the message or templates from your sandbox number to any verified sandbox number.
I will tell you these steps by steps.
Step 1 : Create twilio trail account from here.
Step 2 : go to sandbox and enable your sandbox. After enabling the sandbox you will get the number for your sandbox account.
Step 3 : Now you have to setup your sandbox. here i am sharing screen for that.
In the above image your sandbox number is mentioned. you have to join the sandbox from your phone number by messaging the code "join linen-grouse" to your sandbox number.
Step 4 : after you will send the message you will get message from twilio that now you can use that phone number for Sending/Receiving messages. just see the screenshot for that.
Step 5 : Now enough configuration now we have to go for code...so here we go.
/* Create the class TwilioWhatsapp */
/* Create Visualforce page for that */
Want to see the screen ??
Note : Here for trail account you have to add some of your friend number on twilio account. They have to send the message "join linen-grouse" to your sandbox number(+1415*******).
So that's it for today..!
If you guys got any doubt please don't forget to mention in comment or reach me @ yogeshwer1994@gmail.com
Happy Coding...!!😎
Thanks,
Hope you all guys are good.
So today i am planning to share my discovery with all of the trailblazer community. so from the headlines you might understood what i am going to share "Whatsapp Integration".
I have googled a lot for that how to integrate whatsapp account from CRM. Some python library also i have seen but no good luck in vain.
Last 2-3 months back i have seen that twilio has launched "Twilio Api for WhatsApp".
You can check pricing here.
With trail account you will get the sandbox. You can test your code there.
Here i will not share a lot of things but only i will share you can able to send the message or templates from your sandbox number to any verified sandbox number.
I will tell you these steps by steps.
Step 1 : Create twilio trail account from here.
Step 2 : go to sandbox and enable your sandbox. After enabling the sandbox you will get the number for your sandbox account.
Step 3 : Now you have to setup your sandbox. here i am sharing screen for that.
In the above image your sandbox number is mentioned. you have to join the sandbox from your phone number by messaging the code "join linen-grouse" to your sandbox number.
Step 4 : after you will send the message you will get message from twilio that now you can use that phone number for Sending/Receiving messages. just see the screenshot for that.
Step 5 : Now enough configuration now we have to go for code...so here we go.
/* Create the class TwilioWhatsapp */
public class TwilioWhatsapp {
public String message{get;set;}
public String sendnumber{get;set;}
public void sendWhatsapp(){
String account = 'Your Account Sid';
String token = 'Your Auth Token';
HttpRequest req = new HttpRequest();
req.setHeader('X-Twilio-Client', 'salesforce-' + '2010-04-01');
req.setHeader('User-Agent', 'twilio-salesforce-' + '2010-04-01');
req.setHeader('Accept','Application/json');
req.setHeader('Authorization', 'Basic '+ EncodingUtil.base64Encode(Blob.valueOf(account +':'+ token )));
req.setEndpoint('https://api.twilio.com/2010-04-01/Accounts/'+account+'/Messages.json');
req.setMethod('POST');
req.setBody(''
+ 'From=' + EncodingUtil.urlEncode('whatsapp:+Your SandBOx Number', 'UTF-8')
+ '&To=' + EncodingUtil.urlEncode('whatsapp:'+sendnumber, 'UTF-8')
+ '&Body=' + EncodingUtil.urlEncode(message, 'UTF-8')
);
HttpResponse res = new Http().send(req);
if (res.getStatusCode() >= 200 && res.getStatusCode() < 300) {
String response = res.getBody();
system.debug(response);
}
else{
String response = res.getBody();
system.debug(response);
}
}
}
- Account Sid, Auth Token You will get on your twilio dashboard.
- Your Sandbox number you will get here.(+145*********)
/* Create Visualforce page for that */
<apex:page controller="TwilioWhatsapp" >
<apex:slds />
<apex:form >
<div class="slds-grid slds-gutters">
<div class="slds-col">
</div>
<div class="slds-col">
<apex:outputText styleClass="slds-output" >Sender Number</apex:outputText> <apex:inputText value="{!sendnumber}" styleClass="slds-input" html-placeholder="Add mobile number with country code"/><br/><br/>
<apex:outputText styleClass="slds-output">Message</apex:outputText> <apex:inputTextarea value="{!message}" styleClass="slds-input" html-placeholder="Write Message Here"/><br/><br/>
<apex:commandButton action="{!sendWhatsapp}" value="Send" styleClass="slds-button_neutral"/>
</div>
<div class="slds-col">
</div>
</div>
</apex:form>
</apex:page>
Want to see the screen ??
Note : Here for trail account you have to add some of your friend number on twilio account. They have to send the message "join linen-grouse" to your sandbox number(+1415*******).
So that's it for today..!
If you guys got any doubt please don't forget to mention in comment or reach me @ yogeshwer1994@gmail.com
Happy Coding...!!😎
Thanks,


I feel really happy to have seen your web-page and look forward to so many more entertaining times reading here. Thanks once more for all the details.
ReplyDeleteI just liked the article. It was Very refreshing post with attractive ideas.It was great to read your blog.
Zendesk Whatsapp Integration
360 SMS App’s WhatsApp messaging feature empowers you to send 1-to-1 as well as bulk Whatsapp messages to users. Direct promotional messages usually frustrate users and decrease the likelihood of reading text, but with WhatsApp, the absence of direct promotions leads to a higher chance of getting messages read by users.
ReplyDeletevisit-360sms