Salesforce X ValueFirst SMS & WhatsApp

App URL: https://appexchange.salesforce.com/appxListingDetail?listingId=a0N4V00000GZBMbUAP

Step 1- Login to Salesforce.com with your Username and Password.

Step 2- Install according to the user specific.

Step 3- Click the Grant access and continue button.

Step 4- Installing process will start.

Step 5- After installing the package, go to the Setup and you can find the package details here.

Connected Apps and named Credentials

Step 1- Create Connected App: Setup -> App Manager -> New Connected App

Step 2- Enable OAuth Settings and provide a dummy callback URL. Add scopes for Full access (full), Manage user data via APIs (api), Perform requests at any time (refresh_token, offline_access)

Step 3- Save the record and Click on Manage Consumer Details.

Step 4-Copy the Client ID and Client Secret

Step 5- Create Auth. Provider: Setup -> Auth Provider -> New. Select Provider type as Salesforce. Provide Client ID, Client Secret copied from Connected App as Consumer Key and Consumer Secret respectively and save.

Step 6-From Auth. Provider, copy the Callback URL and update the Connected App to replace the dummy URL with the Auth Provider callback URL.

Step 7-Click on Manage on the created connected app. Click on Edit policies.

Step 8- In IP Relaxation, select Relax IP restrictions

Step 9-Open Setup -> Named Credential and navigate to the External Credentials tab.

Step10- Create new External Credential using Auth Provider created above, set scope as full refresh_token api and click on Save.

Step 11 - Click on New beside Principals and Enter Parameter Name, Identity Type as Named Principal and Scope as full refresh_token api. and Click on Save.

Step 12 – Navigate to Home->Permission Sets->SMS App Edit Access. Click on Clone to clone the Permission Set.

Step 13 – Click on Save.

Step 14 – Now open the cloned Permission Set and click on Manage Assignments.

Step 15 - Click on Add Assignment and select the required user to give Access and Click on Save.

Step 16 – Now click on External Credential Principal Access.

Step 17 – Click on Edit button beside External Credential Principal Access.

Step 18– Now Add the Principals created from Step 11 from Available External Credential Principals to the Enabled External Credential Principals and click on Save.

Step 19 –Navigate to the Named Credential and link it with the External Credential created in the above step.

Step 20- Select the checkbox for callout options and add valuefirst namespace in Named Credential

Step 21- Authenticate the External Credential permission set. Once authenticated, the status will change from Not Configured to Configured.

Step 22- Add the named credential name in Setup Configuration custom metadata type under Named Credential field.

Site Creation

Step 1- Go to the Sites.

Step 2- In the New Site, fill the following attributes: -

  • Site Label
  • Site Name
  • Site Contact
  • Default Record Owner
  • Active the Check box

Step 3- Click the Lens Icon of the Active Site Home Page.

Step 4- Choose any Visualforce Pages.

Step 5- Click on the Save button.

Here we can see the Site has been created.

Step 6- Copy the Site URL and go to Custom Metadata.

Step 7- Click the Manage Records of Setup Configuration.

Step 8- Click the Edit button of Setup Configuration.

Step 9- The Site URL which you copied earlier, needs to be pasted in the Site URL.

Step 10- Click the Save Button.

Step 11- Go back to Sites again and click the Site Label eg.Site_vf.

Step 12- Click Public Access Setting.

Step 13-Click the Enabled Apex Class Access.

Step 14- Select valuefirst.RequestLogApi and valuefirst.WhatsappDeliveryRestAPI from Available Apex Classes to Enable Apex Classes.

Step 15- Go to the ValueFirst For Salesforce App.

Button Creation:-

Step 16- Go to button mapping.

Step 17- Check the two Check-boxes-

  • SMS Button Mapping
  • Whatsapp Button Mapping

Step 18- Fill in the attributes of both SMS Button Mapping and Whatsapp Button Mapping.
For eg- Object API Name- Contact
Field API Name- Phone
Click the Save Button

Step 19- Go to the Object Manager (Setup>>Object manager).

Step 20- Go to any Standard or Custom Object where you have configured the process for eg- Contact.

Step 21- Go to the contact and select the Buttons, Links and Actions.

In the above fig, you can see 4- buttons have been created.

Step 22- Go to Page Layouts.

Step 23- Select Contact Layout and go to the Mobile and Lightning Actions and drag Send SMS and Send WhatsApp Messages onto Salesforce Mobile and Lightning Experience Actions.

Step 24- Now go to the List View Button Layout and click on Edit.

Step 25- Select Send Bulk SMS and Send Bulk WhatsApp Message from the Available button to Selected Buttons and click the Save button below.

26. Sending SMS using developer console (Sync Mode)

  1. Login to the application go to the setup click on developer console
  2. Click on debug, select open execute anonymous window
  3. Enter piece of code and provide sms.smsTemplateId and sms.recordId
  4. Select the records to be executed and click on execute

Piece of code to be executed

List<valuefirst.SendBulkSMSController.SMSRequest> smsList = new List<valuefirst.SendBulkSMSController.SMSRequest>(); valuefirst.SendBulkSMSController.SMSRequest sms = new valuefirst.SendBulkSMSController.SMSRequest(); sms.smsTemplateId = 'a036D000009MgruQAC'; sms.recordId = '0036D00000kzaEnQAI'; sms.runInSync = TRUE; smsList.add(sms); valuefirst.SendBulkSMSController.SMSRequest sms2 = new valuefirst.SendBulkSMSController.SMSRequest(); sms2.smsTemplateId = 'a036D000009MgruQAC'; sms2.recordId = '0036D00000kzaOEQAY'; smsList.add(sms2); valuefirst.SendBulkSMSController.createSMS(smsList);

27. Sending Whatsapp message using developer console (Sync Mode)

  1. Login to the application go to the setup click on developer console
  2. Click on debug, select open execute anonymous window
  3. Enter piece of code and provide sms.smsTemplateId and sms.recordId
  4. Select the records to be executed and click on execute

Piece of code to be executed

List<valuefirst.SendBulkWhatsAppController.smsRequest> smsList = new List<valuefirst.SendBulkWhatsAppController.smsRequest>(); valuefirst.SendBulkWhatsAppController.smsRequest sms1 = new valuefirst.SendBulkWhatsAppController.smsRequest(); sms1.smsTemplateId = 'a076D000003q7rAQAQ'; sms1.recordId = '0036D00000kzaEnQAI'; sms.runInSync = TRUE; smsList.add(sms1); valuefirst.SendBulkWhatsAppController.smsRequest sms2 = new valuefirst.SendBulkWhatsAppController.smsRequest(); sms2.smsTemplateId = 'a076D000003q7rAQAQ'; sms2.recordId = '0036D00000kzaOEQAY'; smsList.add(sms2); valuefirst.SendBulkWhatsAppController.createSMS(smsList)

28. Sending Whatsapp using developer console (ASync Mode)

29. Sending SMS using developer console (ASync Mode)

30. Sending SMS through Flow (Async Mode)

  • Click on Home
  • Search For Flows
  • Click on New Flow, Select Record Triggered Flow.
  • Select any of the required object type ( Ex- Contact)
  • Trigger as created or updated.
  • Click on + and select Action >> Filter By Type >> Apex Action >> Send SMS
  • Provide label of choice
  • Enter the Record ID {!$Record.Id}
  • Enter the SMS object template record id in the SMS Template ID.
  • Click on Save , Save the Flow and Activate.

31. Sending WhatsApp through Flow (Async Mode)

  • Click on Home
  • Search For Flows
  • Click on New Flow, Select Record Triggered Flow.
  • Select any of the required object type ( Ex- Contact)
  • Trigger as created or updated.
  • Click on + and select Action >> Filter By Type >> Apex Action >> Send WhatsApp
  • Provide label of choice
  • Enter the Record ID {!$Record.Id}
  • Enter the WhatsApp object template record id in the WhatsApp Template ID.
  • Click on Save , Save the Flow and Activate.

32. Sending SMS through Flow (Sync Mode)

  • Click on Home
  • Search For Flows
  • Click on New Flow, Select Screen Flow.
  • Select any of the required object type ( Ex- Contact)
  • Trigger as created or updated.
  • Click on + and select Action >> Filter By Type >> Apex Action >> Send SMS
  • Provide label of choice
  • Create a variable of recordID with datatype Text
  • Enter the SMS object template record id in the SMS Template ID.
  • Click on Save , Save the Flow and Activate.

33. Sending Whatsapp through Flow (Sync Mode)

  • Click on Home
  • Search For Flows
  • Click on New Flow, Select Screen Flow.
  • Select any of the required object type ( Ex- Contact)
  • Trigger as created or updated.
  • Click on + and select Action >> Filter By Type >> Apex Action >> Send Whatsapp
  • Provide label of choice
  • Create a variable of recordID with datatype Text
  • Enter the SMS object template record id in the SMS Template ID.
  • Click on Save , Save the Flow and Activate.