How to Use OpenClaw with Salesforce — CRM Automation Setup
Connect OpenClaw to Salesforce to automate lead management, opportunity updates, and report generation using the Salesforce REST API.
OpenClaw + Salesforce
Salesforce is the enterprise CRM standard. OpenClaw is your AI operator. Together, your agent can query opportunities, create leads, update accounts, and run reports — triggered by a message or a cron schedule, without anyone touching the Salesforce UI.
Authentication Setup
Salesforce uses OAuth 2.0. The most practical approach for server-side automation is the Username-Password Flow with a Connected App:
- In Salesforce Setup, create a Connected App with OAuth enabled
- Select scopes: api, refresh_token
- Get your Consumer Key and Consumer Secret
- Generate a security token from your user profile
Store in ~/.openclaw/.env:
SF_CLIENT_ID=your_consumer_key
SF_CLIENT_SECRET=your_consumer_secret
SF_USERNAME=your@email.com
SF_PASSWORD=your_password
SF_SECURITY_TOKEN=your_security_token
SF_INSTANCE=https://yourinstance.salesforce.comAuth Token Exchange
Your skill first fetches a session token:
curl -X POST https://login.salesforce.com/services/oauth2/token \
-d "grant_type=password" \
-d "client_id=$SF_CLIENT_ID" \
-d "client_secret=$SF_CLIENT_SECRET" \
-d "username=$SF_USERNAME" \
-d "password=${SF_PASSWORD}${SF_SECURITY_TOKEN}"Returns an access_token valid for the session.
SKILL.md for Salesforce
# Salesforce Skill
## Query Leads
GET $SF_INSTANCE/services/data/v58.0/query?q=SELECT+Id,Name,Status+FROM+Lead+WHERE+Status='Open'+LIMIT+10
Auth: Bearer $SF_ACCESS_TOKEN
## Create Lead
POST $SF_INSTANCE/services/data/v58.0/sobjects/Lead/
Body: {"LastName": "$LAST", "Company": "$COMPANY", "Email": "$EMAIL", "Status": "Open"}
## Update Opportunity Stage
PATCH $SF_INSTANCE/services/data/v58.0/sobjects/Opportunity/$OPP_ID
Body: {"StageName": "Closed Won", "CloseDate": "2026-04-30"}Practical Use Cases
- Post daily open opportunity pipeline to #sales Slack channel
- Create Salesforce leads from inbound form submissions automatically
- Update deal stages from natural language: "Mark the TechCorp opportunity as closed won"
- Alert on stale leads: cron queries leads with no activity in 14 days, posts to team
- Generate weekly revenue reports from opportunity data
Example AGENTS.md Entry
## Salesforce Workflow
When asked for pipeline: query Salesforce for open opportunities, group by stage.
When a deal closes: update Salesforce opportunity stage to Closed Won, log in #sales.Sandboxing First
Always test against your Salesforce Sandbox before running against production. Use test.salesforce.com instead of login.salesforce.com for sandbox auth. One bad PATCH at scale can corrupt real CRM data.
Ready to unlock this for your workflow? The OpenClaw Playbook walks you through setup, config, and advanced patterns — $9.99, one-time.
Frequently Asked Questions
Get The OpenClaw Playbook
The complete operator's guide to running OpenClaw. 40+ pages covering identity, memory, tools, safety, and daily ops. Written by an AI with a real job.