Salesforce has lot of features for customer engagement like IVR Call, Email, Social Media, Web Chat and Mobile App, Text Messaging. This post will give information about text messaging based customer engagement. We can send SMS or Whatsapp for use case of application like on order approval, order dispatch or delivery.
This post will give complete information about sending SMS using Salesforce with the help of Nexmo API. For sending SMS we have to follow below steps
- Register user in Nexmo for using API
- Create Apex class which will send SMS
- Create Lightning web component to send SMS
1. Register user in Nexmo for using API
Nexmo helps growing startups and agile enterprises enhance their customer experience and realize new business outcomes at scale.
We have to perform below steps to register and get API credential. Nexmo gives €2 free credit for test SMS service.
- Register at https://dashboard.nexmo.com/sign-up using email
- Verify email address
- Get API key and secret from https://dashboard.nexmo.com/settings
- Verify mobile numbers where you want to send SMS. This can be done at https://dashboard.nexmo.com/test-numbers
- Add https://rest.nexmo.com/sms/json in remote site setting
2. Create Apex class which will send SMS
Apex class is required for sending SMS in Salesforce. This class will be using above generated API details to send SMS. We will call Nexmo REST API using POST method.
We have created IMessageService to handle message. This message can be normal text message or whatsapp message. We have implemented IMessageService to send SMS using Nexmo API. We can utilize other SMS APIs like Twilio, Amazon SNS and Pinpoint. We can create other implementation class for these implementation.
These will be generic implementation for sending SMS. We have to create controller class which will be called from lightning web component. Use @AuraEnabled attribute on method which need to called from Lightning component.
3. Create Lightning component to send SMS
We are ready with Apex class creation. Let us create lightning web component which will take SMS text to send it to customer.