Salesforce SMS Integration: Two-Way Texts From a Flow, Replies as Tasks
To text from Salesforce with your own number, connect an Android phone to SMSNET and run the CRM bridge with CRM = "salesforce". A record-triggered Flow calls the bridge with an HTTP Callout, and one SMS goes out. Replies come back as completed Tasks on the matching Contact or Lead, found with a phone search that ignores formatting. STOP ticks a checkbox field. The bridge signs in with OAuth client credentials, so no person's password or session is involved.
What lands on the record
Hi Ronen, your proposal is in your inbox. Questions? Just reply to this message.
Looks good. Can you add the extended warranty?
Salesforce Task on Ronen Mizrahi: Subject "SMS received", Status Completed, with the reply in the description
Step 1: an app for the bridge
The bridge needs its own identity, separate from any person's login.
- Setup → External Client App Manager → New External Client App. Since Spring '26, creating a new Connected App is blocked by default, but an existing Connected App with client credentials works the same way. Enable OAuth settings with the scope
api. - Turn on Enable Client Credentials Flow.
- In the app's policies, set Run As to an integration user who can read Contacts and Leads and create Tasks.
- Copy the consumer key and consumer secret.
In wrangler.toml, set SF_INSTANCE_URL = "https://<your domain>.my.salesforce.com" and SF_CLIENT_ID. Then npx wrangler secret put SF_CLIENT_SECRET. The bridge asks for a token when it needs one, and asks again when it expires.
Step 2: optional opt-out field
Create a Checkbox field with the same API name on both Contact and Lead, for example SMS_Opt_Out__c, and set SF_OPTOUT_FIELD = "SMS_Opt_Out__c". When someone replies STOP (or הסר, once the Hebrew opt-out words are on under Safety → Rules), the bridge sets it to true on whichever object matched.
Step 3: deploy and connect
Download the bridge, set CRM = "salesforce", DEFAULT_COUNTRY_CODE and MESSAGE_TEMPLATE, add SMSNET_API_KEY (test key first) and CRM_TRIGGER_TOKEN, deploy, and point SMSNET's webhook at https://<worker>/smsnet (how).
Step 4: a Flow that texts
- Setup → Named Credentials: create one for
https://<worker>, with an External Credential that uses No Authentication. The token in the path is the credential, so keep the Named Credential's URL to admins. - Flow Builder → Record-Triggered Flow: for example Opportunity, when Stage Name changes to Proposal/Price Quote.
- Add an HTTP Callout action (or invocable Apex if your org uses it) that POSTs to
/crm/<CRM_TRIGGER_TOKEN>. The HTTP Callout wizard builds the body's shape from a sample JSON, and you map each field to a value from the record. This is the body the bridge expects:
{
"phone": "{!$Record.Contact__r.MobilePhone}",
"first_name": "{!$Record.Contact__r.FirstName}",
"record_id": "{!$Record.Contact__r.Id}",
"event_id": "{!$Record.Id}-{!$Record.StageName}",
"sms_text": "Hi {!$Record.Contact__r.FirstName}, your proposal is in your inbox. Questions? Just reply."
}
Field paths depend on your data model. Use the Opportunity's primary contact role or a lookup you already have. event_id makes the Flow safe to re-run: the same opportunity reaching the same stage again produces the same key, and SMSNET doesn't text twice within 24 hours, the time SMSNET keeps a key. If an opportunity can return to the same stage a day later and should text only once ever, add your own condition to the Flow.
How a reply finds the Contact or Lead
Salesforce indexes phone fields in a normalised form. The bridge runs one SOSL search for the international and the national number:
// salesforce.js (excerpt)
const q = `FIND {${digits} OR ${national}} IN PHONE FIELDS
RETURNING Contact(Id, Name), Lead(Id, Name WHERE IsConverted = false) LIMIT 1`;
Converted Leads are skipped, so a reply goes to the Contact that the Lead became. The Task is created with WhoId set to the match, Status = Completed and today's date, so it appears in Activity History rather than in someone's open tasks.
Troubleshooting
| Symptom | Cause |
|---|---|
Salesforce token answered 400 | Client credentials flow is off, or Run As is empty |
| Tasks created but not visible | Sharing or page layout for the Run As user. Check with a report on Tasks with subject "SMS received" |
| A brand new record isn't found for a minute | Search indexing in Salesforce is asynchronous. A reply within seconds of creating the record can miss it |
| Flow error on the callout | The Named Credential URL or the path token is wrong. The bridge answers 404 for a wrong token |
FAQ
Do I need a managed package from AppExchange?
No. The bridge uses the standard REST API with an app you create in Setup. Nothing is installed in your org.
Can I use Salesforce Outbound Messages?
They send SOAP, and the bridge reads JSON. Use a Flow HTTP Callout or a few lines of Apex instead.
Will the replies count against API limits?
Each reply uses one search and one insert, so two API calls. A team getting a few hundred replies a day stays far below typical daily allowances.
Can unknown numbers become Leads?
Yes. With CREATE_UNKNOWN = "1", a reply from an unknown number creates a Lead named "SMS +972..." with company "Unknown (from SMS)" for someone to qualify.
Related guides
This is a spoke of Connect SMS to your CRM. Same bridge: HubSpot, Pipedrive, monday.com. Signature details: Receive SMS webhooks.
Send your first message today
Free plan, no card: 400 messages a month from your own number, with the API, webhooks and MCP included.
Get the app See pricing