Expertise technical

Integrating SMS with Salesforce for large companies in Morocco

Integrate SMS salesforce Morocco: Technical guide with code examples for developers in Morocco.

Integrating SMS with Salesforce for large companies in Morocco
Table of Contents
  1. Salesforce is the standard CRM (Enterprise) of major Moroccan institutions: Banks, Insurance, Branches of multinationals and major real estate operators.
  2. Why Salesforce integration differs from a simple connector
  3. Recommended Architecture: Apex Callout
  4. Data Governance (Conformity with CNDP)
  5. Track the accused of receipt (Object Activity)

Salesforce is the standard CRM (Enterprise) of major Moroccan institutions: Banks, Insurance, Branches of multinationals and major real estate operators.

Unlike a SME that connects two tools via Zapier, the integration of a communication channel (such as the SMS) into the Salesforce architecture of a large Moroccan account is a strategic IT project. It is not just about sending notifications: data governance must be respected, tracing each receipt charge (DLR) in the subject Contact, and satisfy the strict requirements of the CNDP.

Here’s how the architecture should be thought of to connect Salesforce to a Moroccan sovereign SMS API like EnvoiSMS.

Why Salesforce integration differs from a simple connector

Most SMS plugins available on the Salesforce AppExchange (such as SMS Magic or Twilio) suffer from a double defect for the Moroccan market: 1. Data Residence: Using a third-party U.S. cloud app forces the flow of personal data (Names, Telephones of Moroccan Citizens) to transit through servers not approved by the CNDP. 2. Cost of the Scale: Tariffs to destination +212 are often overloaded (Premium Routing) on these international platforms.

A common solution among Moroccan Information Systems Directors (DSIs) is to encode a direct ("Point-to-Point") connection or through a Middleware (type MuleSoft) between Salesforce and the local API.

Recommended Architecture: Apex Callout

The most efficient approach to trigger a SMS from Salesforce without going through a third-party App is to write a Apex (Apex Callout) class that will invoke your Moroccan provider’s REST API.

This class is usually called asynchronously (via @future(callout=true) or a Queueable Apex) from a Trigger (e.g. After Creating an Opportunity) or from a Salesforce Flow.

Simplified example (Apex HTTP Callout) :```java
public class SmsSender {
@future (callout=true)
public static void sendWelcomeSms(String phoneNumber, String customerName) {
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://api.envoisms.ma/v1/messages');
request.setMethod('POST');
request.setHeader('Content-Type', 'application/json');
// Ne jamais hardcoder le token. Utilisez Named Credentials ou Custom Settings.
request.setHeader('Authorization', 'Bearer ' + getApiKey());

String payload = '{"from": "MA_BANQUE", "to": "' + phoneNumber + '", "message": "Bonjour ' + customerName + ', votre dossier de crédit est validé."}';
request.setBody(payload);

try {
HttpResponse response = http.send(request);
if(response.getStatusCode() == 202) {
// Logguer le succès dans un objet personnalisé (ex: SMS_Log__c)
}
} catch (Exception e) {
System.debug('Erreur Callout SMS: ' + e.getMessage());
}
}
}

bash

Data Governance (Conformity with CNDP)

The advantage of this method of Apex Callout direct to EnvoiSMS is control of the data chain: - Salesforce (hosted in Europe via the local instance) pushes the phone number and surname into SSL (encrypted). - The EnvoiSMS API (hosted in Morocco, subject to Moroccan laws) receives the request and sends it over local routes to IAM, Orange and Inwi, with automatic failover between routes. - No third-party app (grey broker) sits between Salesforce and your SMS provider. The compliance audit for the company's DPO (Data Protection Officer) becomes simpler.

Track the accused of receipt (Object Activity)

In order for a call center (using Salesforce Service Cloud) to be effective, the agent needs to know if the SMS alert or OTP was delivered.

The complete architecture requires the creation of a public Endpoint (Salesforce Sites or Apex REST Service) that will listen to the DLR Webhooks from the SMS platform. As soon as the Moroccan operator returns the status DELIVERED (Delivered to the terminal), the EnvoiSMS API notifies Salesforce. The Apex code intercepts this webhook, searches for the message ID, and updates a "Task" (Task) record or a customized "SMS History" (SMS_History__c) object linked to the Contact sheet.

This tailor-made integration requires a few days of development from a Salesforce integrator (Consultant Apex), but it gives the Moroccan company control of its data chain and a telecom bill in MAD.

Why choose EnvoiSMS for your business?

Carrier Delivery

Local routes to IAM, Orange and Inwi, with automatic failover between routes and delivery status sent by webhook.

Cost Optimization

WhatsApp Business API from 0.65 MAD per message with optimal ROI.

Sovereign Data (CNDP)

Full compliance with Moroccan personal data protection regulations (CNDP).

How do I track routing on the IAM, Inwi and Orange networks?
Our local routes to Maroc Telecom (IAM), Orange and inwi, with automatic failover between routes, return a carrier delivery status for every message, by webhook. Delivery time depends on the recipient's carrier and network.
How does the platform manage the format of Moroccan numbers?
EnvoiSMS automatically normalizes the numbers entered (06..., 07..., 00212...) to the E.164 standard (+212) to avoid any delivery failure.

Suggested Articles

SMS Formatting in Morocco: Line Breaks, GSM-7 vs UCS-2 Encoding and Cost Optimization
technical

SMS Formatting in Morocco: Line Breaks, GSM-7 vs UCS-2 Encoding and Cost Optimization

WhatsApp Business Formatting in Morocco: Enriched Text, Emojis and Interactive Buttons
technical

WhatsApp Business Formatting in Morocco: Enriched Text, Emojis and Interactive Buttons

One-Tap Autofill & 1-Click WhatsApp OTP Authentication in Morocco
technical

One-Tap Autofill & 1-Click WhatsApp OTP Authentication in Morocco